English العربية Português Japanese

HTML Paragraphs

Paragraphs are the most basic way to organize text on a web page. Mastering common text tags makes content more readable.

The Paragraph Tag <p>

The <p> tag (paragraph) is used to define a paragraph. The browser automatically adds spacing (margin) before and after paragraphs, creating natural separation between them.

Multiple <p> elements arranged in sequence form the body structure of an article. This is the most common way text is organized on the web — news articles, blog posts, product descriptions, and more are all built upon paragraphs.

HTML
<p>This is the first paragraph. Browsers automatically add spacing before and after paragraphs.</p>
<p>This is the second paragraph, immediately following the first. Paragraphs on the page are naturally separated, creating a clear reading rhythm.</p>
<p>This is the third paragraph. Multiple paragraphs arranged in sequence form a complete article.</p>
▶ Try It Yourself
📌 Note: <p> is a block-level element that occupies a full row width. Even if you place two <p> elements on the same line in your HTML, the browser will render them as two independent blocks.

Line Break and Horizontal Rule

In addition to the paragraph tag, HTML provides two void tags related to text layout: <br> and <hr>.

The Line Break Tag <br>

<br> (break) represents a forced line break in text. It's suitable for addresses, poetry, song lyrics, and other scenarios where manual line break positions are needed. Note: <br> is not for creating paragraph spacing — paragraph spacing should be controlled with <p> or CSS.

The Horizontal Rule <hr>

<hr> (horizontal rule) draws a horizontal line on the page, typically indicating a thematic break or section separator. Like <br>, <hr> is also a void tag.

HTML
<p>This is a line of text,<br>and this is text after a line break in the same paragraph.</p>

<hr>

<p>Above the divider is the first half, below is the second half.</p>

<p>Address example:<br>
123 Main Street<br>
Suite 12<br>
ZIP: 10001</p>
▶ Try It Yourself
⚠️ Note: Don't abuse <br> to create paragraph spacing. If you want larger gaps between paragraphs, use CSS margin instead of stacking multiple <br> tags.

HTML Character Entities

In HTML, certain characters have special meanings (e.g., < and > are used for tags). If you want to display these characters as-is on the page, you must use character entities (also called HTML entities).

Common character entities are listed below:

CharCodeDescription CharCodeDescription CharCodeDescription
 &nbsp;Non-breaking space <&lt;Less than >&gt;Greater than
&&amp;Ampersand "&quot;Double quote '&apos;Single quote
©&copy;Copyright ®&reg;Registered trademark &trade;Trademark
¥&yen;Yen/Yuan &euro;Euro £&pound;Pound
×&times;Multiplication ÷&divide;Division ±&plusmn;Plus-minus
&le;Less than or equal &ge;Greater than or equal &ne;Not equal
&asymp;Approximately &infin;Infinity &sum;Summation
ƒ&fnof;Function ¹&sup1;Superscript 1 ²&sup2;Superscript 2 (squared)
³&sup3;Superscript 3 (cubed) ½&frac12;One half ¼&frac14;One quarter
&larr;Left arrow &rarr;Right arrow &uarr;Up arrow
&darr;Down arrow &hellip;Ellipsis &mdash;Em dash
·&middot;Middle dot &ensp;En space &emsp;Em space

Why do we need escaping? Because when the browser parses HTML, it treats < as the beginning of a tag. If you write <p> directly, the browser thinks you're defining a paragraph tag rather than displaying the text "<p>". Character entities tell the browser: this character is not tag syntax, it's plain text.

HTML
<p>Using character entities to display special symbols:</p>
<ul>
  <li>Less than: &lt; (writing < directly would be mistaken for a tag)</li>
  <li>Greater than: &gt; (writing > directly would be mistaken for a tag end)</li>
  <li>Ampersand: HTML &amp; CSS (displays as HTML & CSS)</li>
  <li>Copyright: Copyright &copy; 2024</li>
  <li>Non-breaking space: Hello&nbsp;&nbsp;World (two spaces)</li>
</ul>
▶ Try It Yourself
⚠️ Common Mistake: Beginners often forget to escape & itself. If you want to display the text &copy; (rather than the copyright symbol), you must write &amp;copy;. If you write &copy; directly, the browser will render it as the © symbol.

📖 Summary

📝 Exercises

  1. Text Layout Practice: Use <p>, <br>, and <hr> tags to write a short text containing: three paragraphs, one address (using <br> for line breaks), and one divider line.
  2. Character Entity Practice: Display the following content on a page: "HTML uses <p> tags to define paragraphs, and the & symbol needs to be escaped with &amp;."
    (Hint: You need to correctly nest character entities so that the browser displays the entity itself, not the character it represents.)
100%