<p> Tag Syntax
Rules for coding HTML p
elements
<body> ... ... flow content allowed ... <p>... phrasing content ... ... phrasing content ...</p> ... </body>
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- To create a paragraph, code a p element where flow content is allowed.
- Begin the p element with a starting <p> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Include any HTML global attributes on the <p> tag as appropriate.
- End the p element with a matching
</p>
closing tag. - Inside the p element, between the
<p>
starting tag and the</p>
ending tag, code the inner HTML phrasing content for the content of the paragraph.
Content of the p element
The content of the b element can include HTML comments, text content and any tags that can be used in phrasing content.
Validation Errors
If the p element is used where phrasing content is expected, the W3C Markup Validation Service will report an error such as:
Line line#, Column col#: HTML element p not allowed as child of HTML element element in this context. Contexts in which element p may be used: Where flow content is expected. Content model for element element: Phrasing content.Other tools that validate HTML code may report a similar error. In electronic publishing, for example:
element "p" from namespace "http://www.w3.org/1999/xhtml" not allowed in this contextTo resolve this type of error, remove the <p> and </p> tags from any context where phrasing content is expected or move the p element and its inner HTML inside one of the HTML elements where flow content is allowed.
If an element that is restricted for use in flow content is included in the inner HTML code of the p element, the W3C Markup Validation Service will report an error like this:
Line line#, Column col#: HTML element element not allowed as child of HTML element p in this context. Contexts in which element element may be used: Where flow content is expected. Content model for element p: Phrasing content.Other tools that validate HTML code may report a similar error. In electronic publishing, for example:
element "element" from namespace "http://www.w3.org/1999/xhtml" not allowed in this contextTo resolve this type of error, remove the tag(s) in error from the inner HTML of the p element, which is restricted to phrasing content, or move the element(s) outside of the paragraph, to a location where flow content is allowed.