<p>: The Paragraph element #
::: section-content
The <p>
HTML element represents a paragraph. Paragraphs
are usually represented in visual media as blocks of text separated from
adjacent blocks by blank lines and/or first-line indentation, but HTML
paragraphs can be any structural grouping of related content, such as
images or form fields.
Paragraphs are
block-level
elements,
and notably will automatically close if another block-level element is
parsed before the closing </p>
tag. See "Tag omission" below.
:::
Try it #
::: section-content ::: iframe ::: {.output-header .border-rounded-top}
HTML Demo: <p> #
Reset :::
::: {#warning-no-script .warning-container} ::: warning The interactive example cannot be shown because JavaScript is disabled. ::: :::
::: {#warning-mathml-not-supported .warning-container .hidden} ::: warning The interactive example cannot be shown because MathML is not supported by your browser. ::: :::
::: {#editor-container .editor-container .tabbed-standard .hidden .border-rounded-bottom editor-type=“tabbed”} ::: {#tab-container .section .tabs} ::: {#tablist .tab-list role=“tablist”} HTML
CSS
JavaScript :::
::: {#html-panel .section .hidden tabindex=“0” role=“tabpanel” aria-labelledby=“html” aria-hidden=“true”} ::: {#html-editor}
Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Antarctica.
<p>Some species live in houses where they hunt insects attracted by artificial light.</p>
::: :::
::: {#css-panel .section .hidden tabindex=“0” role=“tabpanel” aria-labelledby=“css” aria-hidden=“true”} ::: {#css-editor} p { margin: 10px 0; padding: 5px; border: 1px solid #999; } ::: :::
::: {#js-panel .section .hidden tabindex=“0” role=“tabpanel” aria-labelledby=“js” aria-hidden=“true”} ::: {#js-editor} ::: ::: :::
::: {#output .output-container}
Output #
::: :::
::: {.section .console-container .hidden aria-hidden=“true”}
Console Output #
![] clear console
::: {#console .console} ::: :::
::: {#html-output .output .editor-tabbed} %html-content% ::: :::
Content categories | Flow content, palpable content. |
---|---|
Permitted content | Phrasing content. |
Tag omission | The start tag is required. The end tag may be omitted if the <p> element is
immediately followed by an <address> , <article> , <aside> , <blockquote> , <details> , <div> , <dl> , <fieldset> , <figcaption> , <figure> , <footer> , <form> , h1, h2, h3, h4, h5, h6, <header> , <hgroup> , <hr> , <main> , <menu> , <nav> , <ol> , <pre> , <search> , <section> , <table> , <ul> or another <p> element, or if there is
no more content in the parent element and the parent element is not an
<a> , <audio> , <del> , <ins> , <map> , <noscript> or <video> element, or an autonomous
custom element. |
Permitted parents | Any element that accepts flow content. |
Implicit ARIA role | paragraph |
Permitted ARIA roles | Any |
DOM interface | HTMLParagraphElement |
Attributes #
::: section-content This element only includes the global attributes.
::: {#sect1 .notecard .note}
Note: The align
attribute on <p>
tags is obsolete and shouldn't
be used.
:::
:::
Examples #
HTML #
::: section-content ::: code-example [html]{.language-name}
<p>
This is the first paragraph of text. This is the first paragraph of text. This
is the first paragraph of text. This is the first paragraph of text.
</p>
<p>
This is the second paragraph. This is the second paragraph. This is the second
paragraph. This is the second paragraph.
</p>
::: :::
Result #
::: section-content ::: {#sect2 .code-example} ::: iframe ::: ::: :::
Styling paragraphs #
::: section-content By default, browsers separate paragraphs with a single blank line. Alternate separation methods, such as first-line indentation, can be achieved with CSS: :::
HTML #
::: section-content ::: code-example [html]{.language-name}
<p>
Separating paragraphs with blank lines is easiest for readers to scan, but
they can also be separated by indenting their first lines. This is often used
to take up less space, such as to save paper in print.
</p>
<p>
Writing that is intended to be edited, such as school papers and rough drafts,
uses both blank lines and indentation for separation. In finished works,
combining both is considered redundant and amateurish.
</p>
<p>
In very old writing, paragraphs were separated with a special character: ¶,
the <i>pilcrow</i>. Nowadays, this is considered claustrophobic and hard to
read.
</p>
<p>
How hard to read? See for yourself:
<button data-toggle-text="Oh no! Switch back!">
Use pilcrow for paragraphs
</button>
</p>
::: :::
CSS #
::: section-content ::: code-example [css]{.language-name}
p {
margin: 0;
text-indent: 3ch;
}
p.pilcrow {
text-indent: 0;
display: inline;
}
p.pilcrow + p.pilcrow::before {
content: " ¶ ";
}
::: :::
JavaScript #
::: section-content ::: code-example [js]{.language-name}
document.querySelector("button").addEventListener("click", (event) => {
document.querySelectorAll("p").forEach((paragraph) => {
paragraph.classList.toggle("pilcrow");
});
[event.target.innerText, event.target.dataset.toggleText] = [
event.target.dataset.toggleText,
event.target.innerText,
];
});
::: :::
Result #
::: section-content ::: {#sect3 .code-example} ::: iframe ::: ::: :::
Accessibility concerns #
::: section-content Breaking up content into paragraphs helps make a page more accessible. Screen-readers and other assistive technology provide shortcuts to let their users skip to the next or previous paragraph, letting them skim content like how white space lets visual users skip around.
Using empty <p>
elements to add space between paragraphs is
problematic for people who navigate with screen-reading technology.
Screen readers may announce the paragraph's presence, but not any
content contained within it — because there is none. This can confuse
and frustrate the person using the screen reader.
If extra space is desired, use
CSS properties
like
margin
to create the effect:
::: code-example [css]{.language-name}
p {
margin-bottom: 2em; /* increase white space after a paragraph */
}
::: :::
Specifications #
::: _table #
Specification #
HTML Standard
[#
the-p-element]{.small}
:::
Browser compatibility #
::: _table Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
p
1 12 1 Yes 15 1 4.4 18 4 14 1 1.0
:::
See also #
::: section-content
::: _attribution
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5
or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p{._attribution-link}
:::