p ElementThe p element is a block-level element declared by the XHTML 1.1 Text Module (Block Structural)
Elements in the Text Module are:span | br (Inline Structural Support Module)em | strong | q | cite | abbr | acronym | code | var | kbd | samp | dfn (Inline Phrasal Support Module)div | p (Block Structural Support Module)h1 - h6 | blockquote | pre | address (Block Phrasal Support Module)
The p element encloses a single paragraph of text and so it can contain only text and inline elements.
You cannot, for example, include lists, forms, headings or tables within a paragraph. You can, however, include a
line break (using the br element) if it makes sense to start a new line within
your paragraph. User agents usually add top/bottom margins to paragraphs by default, so that adjacent paragraphs are
vertically separated, but CSS can be used to style them as the
author desires.
Although a p element may validly be empty, like so: <, this is
discouraged. See, for HTML 4.01 at the W3C:
*Paragraphs: the P element,
which even goes so far as to say that user agents should ignore empty paragraphs - whether this is also
intended to apply to XHTML is unclear, but there is obviously little semantic meaning to an empty paragraph and
user agents do usually ignore them.
Browsers may also ignore p></p>p elements which contain only whitespace or no printing characters
(e.g. <).
Overall, it is best to remember that a paragraph is not really a paragraph unless it contains something visible
- stick to CSS to control the spacing of items within a page.p> <em> </em> </p>
For example:
<p>Paragraph text may include line breaks<br /> <em>emphasised text</em>,
<img src="/images/images.png" alt="images" /> and many other inline elements...</p>
This renders as (with an appropriate image) as:
Paragraph text may include line breaks
emphasised text,
and many other inline elements...
In the example above, the vertical alignment of the image on its line can be controlled by the
CSS vertical-align property
(e.g. vertical-align:middle).
See also the div element.
There are no #REQUIRED attributes on the p element.
There are no specific attributes declared on the p element.
p element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
p element is:
( #PCDATA | Inline.mix )*
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
pabbr, acronym, br, cite, code, dfn, em, kbd, q, samp, span, strong, varabutton, input, label, select, textareaimgb, big, i, small, sub, sup, ttmapnoscript, scriptdel, insbdoobjectrubypbodyblockquote, divdd, litd, thbutton, fieldset, formmapnoscriptdel, insobject