HTML Paragraph
HTML can divide a document into multiple paragraphs.
HTML Paragraphs
Paragraphs are defined using the <p>
tag.
Example
Note: Browsers automatically add a blank line before and after a paragraph. (The </p>
tag is a block-level element)
Don't Forget the End Tag
Even if you forget to use the end tag, most browsers will display the HTML correctly:
Example
The above example works fine in most browsers, but don't rely on this practice. Forgetting to use the end tag can lead to unexpected results and errors.
Comment: In future versions of HTML, omitting the end tag will not be allowed.
HTML Line Breaks
If you want to break a line without starting a new paragraph, use the <br>
tag:
Example
<p>This<br>paragraph<br>demonstrates line breaks</p>
The <br />
element is an empty HTML element. Since the closing tag has no meaning, it does not have an end tag.
HTML Output - Usage Tips
We cannot determine the exact appearance of HTML output. Screen size and window adjustments can lead to different results.
With HTML, you cannot change the output effect by adding extra spaces or line breaks in the HTML code.
When displaying a page, browsers remove excess spaces and blank lines from the source code. All consecutive spaces or blank lines are counted as a single space. It's important to note that all consecutive blank lines (line breaks) in the HTML code are also displayed as a single space.
(This example demonstrates some HTML formatting issues)
Site Examples
Formatting a Tang Poem in HTML
More Examples
HTML Tag Reference
The tag reference manual on tutorialpro.org provides more information about HTML elements and their attributes.
Tag | Description |
---|---|
<p> | Defines a paragraph |
<br> | Inserts a single line break |