liveBook · Manning

Paragraph element

As explained in Build a Website with ChatGPT

An HTML paragraph element is an HTML element that marks a block of paragraph text.

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

How Build a Website with ChatGPT covers it

How deep it goes
Defines p as paragraph markup and gives step-by-step insertion guidance, without explaining browser internals.
Examples
Demonstrates tagged taglines, section text, article entries, recipe introductions, and portfolio introductions.
What it assumes
Teaches paragraph insertion from opening an HTML file in a text editor, assuming no prior web-page coding knowledge.
What you can do after
Operate/configure it by adding, editing, and separating paragraph text with paired p tags.
How it connects
Connects paragraphs with section, header, main, footer, article, aside, CSS classes, and the br element.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Website with ChatGPT. The section links point to the parts of the book it draws on.