HTML Paragraphs
HTML can divide a document into multiple paragraphs.
HTML Paragraphs
Paragraphs are defined by the <p>
tag.
Example
Note: Browsers automatically add a blank line before and after a paragraph. (The </p>
tag is a block-level element)
Do Not 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 do not rely on this approach. 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 be sure of the exact appearance of the HTML display. Screen size and window adjustments 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 a page, browsers remove excess spaces and blank lines from the source code. All consecutive spaces or blank lines are counted as one space. It is important to note that all consecutive blank lines (line breaks) in the HTML code are also displayed as one space.
(This example demonstrates some HTML formatting issues)
Site Examples
Formatting a Tang Poem in HTML Code
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 |