Master Code
On The Go

Learn. Practice. Build.

Home › Code Snippets › HTML Snippets › Reference › <p>

HTML Reference

<p> — The Paragraph Element

The element that carries the written web. Body text, descriptions, and articles.

Last updated: October 2026

Definition: The <p> element defines a paragraph of text. It is a block-level element that browsers automatically separate from surrounding content with vertical spacing.

🎬 Live Example

Two paragraphs — the browser adds space between them automatically.

This is the first paragraph. Notice how the browser adds space above and below it. You do not need to add any margin or padding yourself.

This is the second paragraph. It sits cleanly below the first with an automatic gap. This is the entire purpose of the paragraph element — the browser handles the spacing.

💡 Without the <p> element, this text would collapse into a single line with no visual separation.

📝

Basic Syntax

<p>This is a paragraph of text.</p>

<p>This is another paragraph. The browser puts space between them.</p>

Paragraphs are block-level. Each one sits on its own line with automatic margin.

⚙️ Global Attributes

The <p> element has no specific attributes. It uses the standard global attributes:

Attribute Purpose
idUnique identifier.
classClass names for styling.
styleInline CSS.
titleTooltip on hover.
langLanguage of the paragraph content.
dirText direction: ltr, rtl, auto.
aria-*ARIA attributes for accessibility.
1

Multiple Paragraphs

The natural rhythm of any article or blog post.

<p>This is the opening paragraph.</p>

<p>This is the second paragraph.</p>

<p>And the third paragraph.</p>
2

Inline Elements Inside Paragraphs

Paragraphs can contain any inline element — links, emphasis, code, spans.

<p>
    This is a <strong>bold word</strong> and
    an <em>emphasized word</em>. Here is a
    <a href="/about">link</a> and some
    <code>inline code</code>.
</p>
3

Non-Breaking Space

HTML collapses multiple spaces into one. To force a space, use the entity.

<p>Multiple&nbsp;spaces&nbsp;stay.</p>

<p>Regular     spaces    collapse.</p>

💡 Warning: &nbsp; is only for forcing spaces in small snippets (like "5 kg"). Do not use it for layout spacing — that's what CSS is for.

4

Styling Paragraphs

Common CSS patterns for readable paragraph text.

p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 1rem;
    max-width: 65ch;  /* readable line length */
    color: #cbd5e1;
}

/* Drop cap on the first letter */
p:first-of-type::first-letter {
    font-size: 3rem;
    font-weight: 900;
    float: left;
    margin-right: 0.25rem;
}
5

Poetry or Address Line Breaks

Use <br> only for semantic line breaks within a single thought.

<p>
    Roses are red,<br>
    Violets are blue,<br>
    HTML paragraphs have margins,<br>
    And so do you.
</p>

<p>
    123 Main Street<br>
    Springfield, USA 12345
</p>

Do not use <br><br> for spacing between paragraphs. Use separate <p> elements instead. <br> is for line breaks within a single block of text.

🎯 What Can Go Inside <p>

Allowed Not allowed
<a><div>
<span><p> (nested)
<strong>, <em><h1>–<h6>
<code>, <kbd><ul>, <ol>
<br><section>, <article>
<img> (inline)<form>, <table>
<mark>, <time><video>, <audio>

💡 Rule: If the element represents a block of content (headers, sections, lists), it cannot go inside a <p>. Only inline content is allowed.

⚠️ Common Mistakes

♿ Accessibility Notes

❓ Frequently Asked Questions

What is the HTML <p> tag?

The <p> tag defines a paragraph of text. It is a block-level element that automatically adds spacing above and below itself. It is the most-used element for body content on the web.

Does <p> add line breaks?

Yes. <p> is a block-level element, so browsers automatically add a blank line above and below it. Use CSS margin if you need to change this spacing.

Can <p> contain other block elements?

No. <p> can only contain inline content: text, <span>, <a>, <strong>, <em>, <code>, <br>, and similar inline elements. Block elements like <div>, <h1>, or another <p> will close the paragraph early.

How do I add multiple spaces in a paragraph?

HTML collapses multiple spaces into one. To force spaces, use &nbsp; (non-breaking space) or use CSS white-space: pre-wrap. For long blocks of pre-formatted content, use <pre> instead.

Should I use <br> inside a paragraph?

Only for semantic line breaks, like poetry or addresses. For visual spacing between paragraphs, use separate <p> elements with CSS margins. Using <br> for spacing is bad practice.

🎯 What's Next?

← All HTML Reference