Nothing is for sale here. Freewill tips keep the site running. Want to help? → Tip via Paypal

Paragraphs and Line Breaks

Unlike text editors, browsers do not display the carriage returns (created by pressing the Enter key) that you enter into your source code. A carriage return merely creates a single space. Browsers also display a continuous series of spaces as just one space. If you typed the following two lines exactly as shown below in your web page’s source code:

It is wise to taste a great        diversity of
thought, just be careful of what you swallow.

…a browser would display it like this:

It is wise to taste a great diversity of thought, just be careful of what you swallow.

As you can see, the extra spaces between the words great and diversity are reduced to one space, and the browser didn’t wrap the text to the next line where I did.

A browser will not start a new line of text until you either code a new line into your source code, or the text reaches the end of the available horizontal space, at which point it wraps to the next line. If there's no container that limits the width the text will keep going ad infinitum, causing a horizontal scroll bar.

So, you need to tell the browser to start a new line. Amazing how I know just what you need to do, eh? crazy smile

There are two basic tags used to create line breaks. One tag creates a single line break; the other creates a double line break. The tag for a single line break is called, appropriately enough, a break tag. It is coded like this:

<br>

The break tag is one of the so-called empty tags, which simply means it doesn’t have a corresponding closing tag. Wherever you code a break tag into your page the content that follows would immediately drop down to the next line with no more code needed.

note To be compliant with XHTML, add a space and forward slash (<br />) to the end of any empty tag to make it self-closing. For standard HTML pages code the break tag as I show above.

The paragraph tag creates two line breaks. Text following a paragraph tag will drop down two lines, leaving an empty line in between the lines that precede and follow the paragraph tag. It's like writing two <br> tags in a row. A paragraph tag is written as follows:

<p>

In HTML, a closing paragraph tag is optional, but it can cause some quirky problems in certain instances. The closing tag is required in XHTML. I recommend always using the closing tag. Here’s an example:

<p>
Your paragraph of text goes here.
</p>

Gee, this stuff sure is easy. You only need to learn more little bits and pieces of code like this to do more stuff, and the more you learn, the more you can do!