<br>

HTML <br> Tag

Definition

Definition (定义)

The HTML <br> tag defines a line break. Unlike the <p> tag defining a paragraph, an empty indent is not added before the line.

Syntax

Syntax (语法)

The <br> tag is empty, which means that the closing tag isn’t required. But in XHTML, the (<br>) tag must be closed (<br/>).

Example of the HTML <br> tag:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document</title>
 </head>
 <body>
   <h1>Example of the &lt;br&gt; tag usage.</h1>
   <p> Inside the paragraph, we can put the tag &lt;br /&gt;, <br> to transfer a part of the text to another line if necessary.</p>
 </body>
</html>

Usage

Usage (使用)

The <br> tag is used to enter line breaks. It is useful for writing addresses, poems or song lyrics.

Do not use <br> tag to separate paragraphs. It is very problematic to use <br> tag to separate the paragraph for the people who navigate through the screen reading technology. Use <p> elements and CSS margin property to control spacing.

Example of the HTML <br> tag for entering line breaks:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document</title>
 </head>
 <body>
   <h1>Example of the &lt;br&gt; tag usage</h1>
   <blockquote>
     But I'm not the only one<br>
     I hope some day you'll join us<br>
     And the world will live as one.<br>
   </blockquote>
   <cite>John Lennon "imagine"</cite>
 </body>
</html>

Attributes

Attributes (属性)

AttributesValueDescription
clearSpecifies how to process the next line if the text wraps around the floating element.Not used in HTML5.
allReverses the flow around the element from the right and left edges at the same time.
leftReverses the flow from the left side of the element placed after the <br> tag.
rightReverses the flow from the right side.
noneCancels the action of an attribute.

The <br> tag supports the Global Attributes and the Event Attributes.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部