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.

Example

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.

Example

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:

Core principle: When the browser encounters <, it treats it as the start of a tag. To display it as a "less than" sign, you must write &lt;. Similarly, the & symbol itself needs escaping because it is the prefix for entity references.

The 5 most commonly used escape characters:

Char Code Description
  &nbsp; Non-breaking space
< &lt; Less than
> &gt; Greater than
& &amp; Ampersand
" &quot; Double quote
📌 See Chapter 11: For the complete list of entity symbols, differences between named entities and numeric references, and special whitespace characters, refer to Chapter 11: HTML Character Entities.

❓ FAQ

Q What's the difference between <p> and <br>? When should I use each?
A <p> is a paragraph tag that creates an independent text block — the browser automatically adds spacing before and after. <br> is a line break tag that forces a new line within the same paragraph, without creating a new paragraph. Simply put: <p> for "start a new paragraph," <br> for "break a line within the same paragraph." A common mistake is using multiple <br> to create paragraph spacing — this is wrong; use multiple <p> tags instead.
Q Why shouldn't I use multiple <br> to create spacing?
A Using multiple <br> for spacing is an outdated web design habit — absolutely not recommended. Three reasons: 1) Semantically wrong — <br> means "line break," not "spacing," like using Enter key instead of paragraph breaks; 2) Hard to maintain — to adjust spacing, you'd need to delete or add multiple <br>, while CSS margin only needs one value change; 3) Responsive issues — multiple <br> create inconsistent spacing across different screen sizes. Correct approach: use <p> tags for paragraphs, CSS margin for spacing control.
Q What's the difference between &nbsp; and a regular space in HTML?
A Regular spaces in HTML get "collapsed" — multiple consecutive spaces display as just one. This is an HTML design feature so that indentation in source code doesn't affect page display. &nbsp; (non-breaking space) has two functions: 1) It doesn't collapse — multiple &nbsp; display as multiple spaces; 2) It prevents browsers from breaking lines at that point — words connected by &nbsp; are treated as a unit and won't be split across lines. Common uses: between numbers and units (like 100&nbsp;px), between names (like John&nbsp;Doe).

📖 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 &." (Hint: You need to correctly nest character entities so that the browser displays the entity itself, not the character it represents.)
100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏