HTML Paragraphs

You can divide an HTML document into several paragraphs.

HTML Paragraphs

Paragraphs are defined by the <p> tag.

Example

<p>This is a paragraph</p>
<p>This is another paragraph</p>

Try It Yourself

Note:Browsers will automatically add blank lines before and after paragraphs. (The <p> is a block-level element)

Tip:Using empty paragraph tags <p></p> to insert a blank line is a bad habit. Use the <br /> tag instead! (But do not use the <br /> tag to create lists. Do not worry, you will learn about HTML lists later.)

Do not forget to use end tags

Even if you forget to use end tags, most browsers will display HTML correctly:

Example

<p>This is a paragraph</p>
<p>This is another paragraph</p>

Try It Yourself

The example above works in most browsers, but do not rely on this practice. Forgetting to use end tags can produce unexpected results and errors.

Note:In future HTML versions, it will not be allowed to omit end tags.

Tip:Closing HTML with end tags is a tried and tested HTML writing method that stands the test of time. Clearly marking where an element begins and ends makes the code easier to understand for both you and the browser.

HTML line break

If you want to break a line without creating a new paragraph, please use the <br /> tag:

<p>This is<br />a paragraph with line breaks</p>

Try It Yourself

The <br /> element is an empty HTML element. Since the closing tag has no meaning, it does not have an end tag.

<br> or <br />

You may find that <br> and <br /> are very similar.

In XHTML, XML, and future versions of HTML, HTML elements without closing tags (closing tags) are not allowed.

Even if <br> displays correctly in all browsers, using <br /> isLong-term protection.

HTML Output - Useful Tips

We cannot determine the exact effect of HTML display. The size of the screen and adjustments to the window can lead to different results.

For HTML, you cannot change the output effect by adding extra spaces or line breaks in the HTML code.

When displaying the page, the browser will removeSource codeExcessive spaces and blank lines. All consecutive spaces or blank lines are counted as one space. It should be noted that all consecutive blank lines (line breaks) in HTML code are also displayed as a space.

Try It Yourself

(This example demonstrates some formatting issues in HTML)

Examples from this page

HTML Paragraphs
How to display HTML paragraphs in a browser.
Line Break
Using line breaks in HTML documents.
Typing a Tang poem in the formatting of HTML code
Browsers will omit extra whitespace characters (spaces or returns, etc.) in the source code when displaying HTML.

More Examples

More Paragraphs
The default behavior of paragraphs.

HTML Tag Reference Manual

The CodeW3C.com Tag Reference Manual provides more information about HTML elements and their attributes.

Tag Description
<p> Define a paragraph.
<br /> Insert a single line break (newline).