Learning Resources
 

Spacing and Breaks


Two places exist within an HTML file where you might like to add breaks:

    In between tags, to help you differentiate between sections of the page
    In between lines of text within the body of the page
 
Spacing and Breaks Between Tags
The first place you might like to add breaks is in between tags, as in the following example.


My First Web Page


Although this is not required, most people use the ENTER or RETURN key to separate tags with line breaks. Others also indent tags that are contained within other tags, as in the preceding example: the title tag is indented to show it is contained or nested within the head tag. This may help you to identify the tags more quickly when viewing the page in a text editor.

Spacing Between Lines of Text
The second place you add breaks is between the lines of text in the body of the page. If you use the RETURN or ENTER key on your keyboard to add a line break in between two lines of text on your page, that line break will not appear when the browser displays the page.
"https://www.w3.org/TR/xhtml1/DTD/transitional.dtd">


My first Web page


Welcome.
Thank you for visiting my first Web page. I have several other pages
that you might be interested in.



To make those line breaks appear, I’d have to use a tag to tell the browser to insert a line break. Two tags are used for breaks in content.




The br tag inserts a simple line break. It tells the browser to drop down to the next line before continuing. If you insert multiple br tags, the browser will drop down several lines before continuing.

The p tag signifies a paragraph break. The difference between the two is that paragraph breaks cause the browser to skip a line, while line breaks do not. Also, the p tag is considered a container tag because its opening and closing tags should be used to contain paragraphs of content. The br and p tags are discussed in more detail in Chapter 4.

If I enclose each of these paragraphs in p tags, like the following:

Welcome.


Thank you for visiting my first Web page. I have several other pages that you might be interested in.



the browser will know to separate them with a blank line. The following screen shows how the browser displays the text now that I have contained each of the paragraphs in p tags.

In addition, HTML neither recognizes more than a single space at a time nor interprets a tab space as a way to indent. This means that in order to indent a paragraph or leave more than one space between words, you must use style sheets or special characters.