If you find this helpful, please click the Google Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.) |
The <br/> Tag in HTML 5
The break tag (<br/>) is used to force a line break in HTML code. It is one of the inline tags used to group and separate content in HTML. A similar tag, the <wbr/> tag, provides a way to suggest an optional line break to the web browser.
According to the HTML 5 specification, br elements must be used only for line breaks that are actually part of the content, as in poems or addresses.
For example:
John & Jane Doe
123 Second St.
Riverside, LA 17654
This is an actual example of the <br> tag example code below.
For content other than things like addresses and poems, there are various alternatives to the <br/> tag for HTML code that can control how the content is laid out over multiple lines:
- an unordered list with list item tags
- a paragraph tag for each line
- white-space: pre for preformatted text
<br/> Break Tag Syntax
<body> ... ... phrasing content expected ...<br/>... ... </body>
Rules for coding the HTML br element
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code the br element where phrasing content is expected.
- The br element consists of a standalone <br/> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Include any HTML global attributes on the <br> tag as appropriate.
- Since the br element is a void element, it should always be coded as a self-closing tag terminated with the delimiter string
/>
.
<br/> Content Model
Contents of the <br/> Tag
Content: Empty. Any properties are coded using global attributes.
Since the <br/>
tag is a void element, it is not allowed to have any content, even HTML comments and therefore should always be coded as a self-closing standalone tag, ending with the delimiter string />
rather than just >
(<br/>
).
<br/> Tag Attributes
Attributes of the <br> tag
global attributes | In addition to the personal attributes of the <br> tag below, any of the common HTML attributes can also be coded. |
<br/> Break Tag Examples
Examples of the br
tag in HTML 5
<br> tag example
(see <br> tag demo above)
<p>John & Jane Doe<br/> 123 Second St.<br/> Riverside, LA 17654</p>
Changes in HTML 5 - <br/> Tag
What's new in HTML 5
Differences between HTML 5 and earlier versions of HTML
The following attributes should not be coded on the <br/> tag because they either have been deprecated or were never officially supported:
clear
In ployglot HTML documents the <br/>
tag is coded as a self-closing tag the same as in the 2000-2010 Recommendations from the W3C HTML Working Group. Those specifications changed the ending delimiter to />
from >
in older recommendations. They also defined the HTML namespace for the br element type name and the names of other HTML element types.