- Mar 28, 2003
Starting a New Paragraph
(X)HTML does not recognize the returns or other extra white space that you enter in your text editor. To start a new paragraph in your Web page, you use the p tag.
To begin a new paragraph:
Type the contents of the new paragraph.
Type </p> to end the paragraph.
In HTML, the closing </p> tag is optional. However, it is required both in XHTML and when applying styles to a paragraph. Therefore, I recommend always ending a paragraph with </p>.
Figure 3.12 Enclose each paragraph in opening and closing p tags. If you don't close them (which is perfectly legal in HTML but not XHTML), styles won't be applied properly.
You can use styles to format paragraphs with a particular font, size, or color (and more). For details, consult Chapter 10, Formatting with Styles.
To control the amount of space between lines, consult Setting the Line Height on page 164. To control the amount of space after a paragraph, consult Adding Padding around an Element on page 188 or Setting the Margins around an Element on page 189.
Figure 3.13 The amount of space inserted by default with a p tag depends on the size of the text surrounding it.
One quick and dirty (and valid) trick for adding extra space between paragraphs is to type (a non-breaking space) between each additional p element. Better yet, use CSS (see pages 188189).
You can align the text in the paragraph by typing align="direction" in the opening p tag, where direction is left, right, center, or justify. But note that the align attribute has been deprecated in favor of style sheets (see page 171).