HTML Paragraph
HTML can divide a document into several paragraphs.
HTML Paragraph
The paragraph is defined by the <p> tag.
Example
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Note: The browser will automatically add blank lines before and after the paragraph. (</p> is a block-level element)
Don't Forget the Closing Tag
Even if you forget to use the closing tag, most browsers will display the HTML correctly:
Example
<p>This is a paragraph
<p>This is another paragraph
The above example is fine in most browsers, but don't rely on this approach. Forgetting to use the closing tag can produce unexpected results and errors.
Note: In future HTML versions, it is not allowed to omit the closing tag.
HTML Wrapping
If you want to wrap (new line) without creating a new paragraph, use the <br> tag:
Example
<p>This<br>paragraph<br>demonstrates the effect of branches</p>
The <br /> element is an empty HTML element. Since the closing tag has no meaning, it has no closing tag.
HTML Output - Usage Reminder
We are unable to determine the exact effect of the HTML being displayed. The size of the screen and the adjustment of the window may lead to different results.
For HTML, you cannot change the output effect by adding extra spaces or line breaks in the HTML code.
When the page is displayed, the browser will remove extra spaces and blank lines in the source code. All consecutive spaces or blank lines will be counted as one space. It should be noted that all consecutive blank lines (newlines) in the HTML code are also displayed as a space.
(This example demonstrates some HTML formatting issues)
Examples of This Site
HTML paragraphs
How to display HTML paragraphs in the browser.
Line break
Use line breaks in HTML documents.
Typesetting in HTML code
browser displays HTML, it will omit extra blank characters (spaces or carriage returns, etc.) in the source code.
More Examples
More paragraphs
The default behavior of paragraphs.
HTML Tag Reference Manual
The tag reference manual of the tutorial provides more information about HTML elements and their attributes.
Label | Description |
---|---|
<p> | Define a paragraph |
<br> | Insert a single line break (line break) |