<p>
A paragraph of text.
- Display
- block
- Closing tag
- Required
- Permitted content
- Phrasing content
Example
#<p>HTML describes the structure of a page: what's a heading, what's a paragraph, and what's a list.</p>
<p>CSS takes care of the look, and JavaScript the behavior.</p>Definition and usage
#The <p> element marks a paragraph, the basic unit of text on a page. By default, the browser adds a margin above and below the paragraph equal to the height of one line.
A paragraph can only contain phrasing content: text, links, emphasis, images, and other inline elements. You can’t put a list, a table, a heading, or another paragraph inside it. If you try, the browser will close the paragraph on its own right before such an element.
The closing </p> tag can technically be omitted, but it’s always worth writing it. The code is then easier to read, and the automatic closing won’t catch you by surprise.
Syntax
#<p>Paragraph content.</p>Attributes
#This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.
Default CSS
#Most browsers display this element with these default styles:
p {
display: block;
margin-block: 1em;
}Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Don’t create spacing with empty
<p></p>paragraphs or a string of<br>tags. Set spacing in CSS. - Short paragraphs are easier to read, especially on a phone.
Related entries
#- <br>A line break at the point it’s inserted, without starting a new paragraph.
- <div>A generic block-level container with no meaning, for grouping elements and styling.
- <span>A generic inline container with no meaning, for styling a piece of text.
- <blockquote>A longer quotation from another source, displayed as a separate, indented block.
- <pre>Preformatted text: it preserves spaces, tabs, and line breaks exactly as they appear in the code.
Spotted a mistake or missing an example? Write to us.