Browsers usually format paragraphs to fit into the horizontal space (screen or window width) available.
Paragraphs are usually rendered flush left with a ragged right margin. The ALIGN attribute can be used to specify explicitly the horizontal alignment.
attribute name | possible values | meaning | notes |
---|---|---|---|
ALIGN | LEFT, CENTER, RIGHT | alignment of the paragraph (flush left, centered, flush right) | deprecated in HTML 4.0 |
The default is left alignment, but this can be overridden by an enclosing DIV (or CENTER) element.
<P> This is a normal text paragraph which contains so many characters that it will most probably be split into several lines by a browser. </P>A contrived example:
<P> This is a normal text paragraph with no attribute for horizontal alignment. Nothing special. </P> <P ALIGN=CENTER> <B>This is a paragraph which should be centered. It should also appear in bold face but this results from explicit use of a B element. Centering itself should not affect the font.</B> </P> <P ALIGN=RIGHT> This is a paragraph which should be rendered flush right. It is difficult to see why you would ever <EM>like</EM> to use this option! </P>See also the examples about BLOCKQUOTE, one of which makes reasonable use of ALIGN=RIGHT.
If you intend to use P for alignment purposes, such as centering text, remember that a P element may only contain text elements. The DIV element may contain block elements, too.
There is no way in HTML (in HTML 3.2 at least) to make text appear "justified" (solid-right), unless you want to resort to using the PRE element. More exactly, such presentation issues are browser-dependent, and the great majority of browsers use ragged right margin.
The end tag </P> can always be omitted, and it usually is omitted. It is, however, advisable to use explicit </P> tags for the following reasons:
Paragraphs cannot be nested. (This is the other side of the "nice" feature that </P> can be omitted.) One way of simulating subparagraphs is to use BR elements around a piece of text within a P element. Another way is to use list elements (such as UL) instead of P elements.
The division into lines in the rendering usually does not match the HTML source. See the section Division into lines and the use of blanks and tabs.