Breaks and Spacing
As I said in Elements of a Web Page, text in the body section
does not need any tags for it to appear on a web page. Tags are
used to format the text. It is possible to type one long paragraph
in HTML and never use a tag. But what if you want to divide the text
into paragraphs? How do you do that?
What if you want to begin typing on a new line - like this one?
How do you do that?
Vertical Spacing
HTML has two tags for adding vertical spacing to your web page:
- The <br /> (break) tag is used to single space or break the line of text.
- The <p /> (paragraph) tag is used to double space.
The paragraph tag can also have attributes - you'll learn about them next week.
When used to space down one or two lines, the <br /> and <p /> tags are
single tags: they do not have a separate closing tag. New in XHTML: All tags must be closed. The <br> tag was allowed in HTML 4.0, but it now requires a "/".
Another single tag is the
<hr /> tag. It prints a line across the page followed by a single space. Like the
<p /> tag, the <hr /> tag can also have attributes - we'll learn more about them later. (When the <p /> or <hr />
tags have attributes, they also have a separate closing tag.)
To single space, use the <br /> tag at the end of the line or at the beginning of the next line: <br />
To double space, use the <p /> tag at the end of the line or at the beginning of the next line: <p />
To print a line followed by a single space, use the <hr /> tag: <hr />
Horizontal Spacing
One of the interesting things about HTML code is that no matter how many spaces you have
in your code, the browser only displays one space. It also ignores the Enter key,
substituting a space for a paragraph mark. There are ways to put extra horizontal spaces in your code.
We will learn about them later.
To center a line of text, you can use the center tag:
e.g., <center>Text to be centered</center>.
This tag is a deprecated tag. We will learn another way to do this later.
Back to the Week 2 Schedule