HTML Reference ยท Text Content
The <p> element
Reference for the HTML <p> element: paragraphs of text, what may go inside one, automatic closing by the parser, spacing with CSS, and technical details.
The <p> element marks a paragraph: a block of related sentences, or any run of phrasing content that forms one unit, such as a short caption or an address line. It is the most common text element on the web. Browsers display paragraphs as blocks with space above and below.
<p>The museum opens at ten. Tickets are sold at the door.</p>
Try it
Attributes
This element has no attributes of its own. It accepts the global attributes. The old align attribute is obsolete; use the CSS text-align property.
Usage notes
- Only phrasing content inside. A
<p>cannot contain block elements such as<div>, lists, tables, headings or another<p>. If you write<p><div>โฆ</div></p>, the parser closes the paragraph before the<div>, and the stray</p>creates an extra empty paragraph. - Don't use empty paragraphs for space. Control spacing with CSS
margininstead of<p></p>or<p> </p>. - Line breaks. Use
<br>only when the break is part of the content, such as in a poem or an address. For new ideas, start a new paragraph. - Not for headings. A short bold paragraph is not a heading; use
<h1>โ<h6>. - Optional end tag. The parser closes a
<p>automatically when a block element (like another<p>, a list, a heading or a<div>) starts. Always writing</p>avoids surprises.
Technical summary
| Content categories | Flow content, palpable content |
| Permitted content | Phrasing content |
| Tag omission | Start tag required. The end tag may be omitted if the paragraph is immediately followed by a block-level element such as <address>, <article>, <aside>, <blockquote>, <details>, <dialog>, <div>, <dl>, <fieldset>, <figcaption>, <figure>, <footer>, <form>, <h1>โ<h6>, <header>, <hgroup>, <hr>, <main>, <menu>, <nav>, <ol>, <p>, <pre>, <search>, <section>, <table> or <ul>; or if there is no more content in the parent and the parent is not an <a>, <audio>, <del>, <ins>, <map>, <noscript>, <video> or autonomous custom element |
| Permitted parents | Any element that accepts flow content |
| Implicit ARIA role | paragraph |
| DOM interface | HTMLParagraphElement |
| Default display | block (with a margin of about 1em above and below) |
Browser support
Supported in every browser.
Related
<br>โ a line break within a paragraph<h1>โ<h6>โ headings<pre>โ text that keeps its spacing<div>โ a generic block container- Lesson: Headings and Paragraphs
- Lesson: Block and Inline Elements
- Lesson: Formatting Text