The HTML paragraph element, written as p, marks a chunk of text as a paragraph. Put the opening <p> tag before the text and the closing </p> tag after it. Paragraphs can appear in sections and in areas such as a header, main content, footer, article, or aside. section 12.2.1
Write separate paragraphs
Use one p element for each paragraph of text: <section> <h2>Section heading</h2> <p>First paragraph.</p> <p>Second paragraph.</p> </section> Each pair of tags keeps its paragraph distinct when the browser renders the page. section 6.4
To add a paragraph in an existing article, section, or aside:
- Open the HTML file and place the cursor immediately after the closing tag of the element or paragraph that comes before it. section 12.2.5
- Start a new line, type <p>, add the paragraph text, and finish with </p>. A code editor may insert the closing tag automatically. section 12.2.5
- For another paragraph, begin after the current </p> tag and repeat the process. section 12.2.5
Keep the tags while customizing text: edit what appears between <p> and </p>, but do not delete either tag. For text that needs separate paragraphs, give each paragraph its own tag pair. A class can identify a paragraph for CSS styling, such as <p class="entry-text">. section 3.4 section 5.4
Use paragraphs for paragraph text, not merely to force a new line without extra space. Where consecutive short lines need no extra spacing, replace paragraph tags with the br line-break tag instead. section 4.3.1
<main>
<details>
<summary class="entry-title">Title of Entry 1</summary>
<p class="entry-date">24 July 2023</p>
<p class="entry-text">Entry text goes here.</p>
<p class="entry-text">Another paragraph goes here.</p>
<p class="entry-text">You can keep going if you want.</p>
</details>
This entry example shows three separate paragraph elements, all sharing the entry-text class so their text can be styled together. section 5.4
