HTML paragraph
HTML can divide the document into several paragraphs.
HTML Paragraph
A paragraph is defined through the <p> tag.
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <p>这是一个段落。</p> <p>这是一个段落。</p> <p>这是一个段落。</p> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
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:
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <p>这是一个段落 <p>这是另一个段落 </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
The above example will work fine in most browsers, but don't rely on this approach. Forgetting to use closing tags can produce unexpected results and errors.
Note: In a future version of HTML, omitting the closing tag will not be allowed.
HTML Line Wrapping
If you wish to wrap lines (new lines) without creating a new paragraph, use the <br /> tag:
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <p>这个<br>段落<br>演示了分行的效果</p> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
The<br /> element is an empty HTML element. Since a closing tag doesn't make any sense, it doesn't have a closing tag.
<br/> For more introduction to tags, please refer to the detailed explanation of <br/> tag in [HTML Dictionary].
HTML Output - Usage Reminder
We cannot determine the exact effect of the HTML being displayed. The size of the screen, as well as adjustments to the window, may lead to different results.
With HTML, you cannot change the output by adding extra spaces or line breaks to the HTML code.
When displaying the page, the browser will remove extra spaces and blank lines in the source code. All consecutive spaces or empty lines are counted as one space. Note that all consecutive empty lines (newlines) in HTML code are also displayed as a single space.
(This example demonstrates some HTML formatting issues)
HTML Paragraph
How to display HTML paragraphs in the browser.
Line breaks
Use line breaks in HTML documents.
Typesetting a Tang poem in HTML code
When the browser displays HTML, it will omit redundant whitespace characters (spaces or carriage returns, etc.) in the source code.
More examples
More paragraphs
Default behavior for paragraphs.
HTML Tag Reference Manual
W3CSschool's Tag Reference Manual provides more information about HTML elements and their attributes.
Tag | Description |
---|---|
##<p> | Define a paragraph|
<br> | Insert a single line break (line break)