HTML <br> Tag
The HTML <br>
tag is used for creating the 'br' element, which represents a line break in an HTML document.
The <br>
element is classified as a "void element" as it has no content. This also means that no end tag is required (or allowed for that matter).
The <br>
tag must be used only for line breaks that are actually part of the content, as in poems or addresses. It should not be used for separating thematic groups in a paragraph. To separate thematic groups, use multiple <p>
tags instead.
Also see the <wbr>
tag for specifying a line break opportunity.
Syntax
The <br>
tag is written as <br>
at the point where the line break should occur.
Like this:
Examples
Addresses
One good example where the <br>
tag can be used is for presenting addresses (such as street addresses). This is because addresses usually have one or more line breaks as part of the content.
Poetry/Lyrics
Another example of <br>
usage is with poetry or song lyrics.
Line Breaks and CSS
Although it is used for creating a line break, the HTML5 specification allows for the <br>
element to be styled in such a way that the browser does not render line breaks. In particular, it reads:
While line breaks are usually represented in visual media by physically moving subsequent text to a new line, a style sheet or user agent would be equally justified in causing line breaks to be rendered in a different manner, for instance as green dots, or as extra spacing. - HTML5 Specification
The <wbr>
Tag
Also see the <wbr>
tag for specifying a line break opportunity.
Attributes
Attributes can be added to an HTML element to provide more information about how the element should appear or behave.
The <br>
element accepts the following attributes.
Attribute | Description |
---|---|
None |
Global Attributes
The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <br>
tag , as well as with all other HTML tags.
accesskey
autocapitalize
class
contenteditable
data-*
dir
draggable
hidden
id
inputmode
is
itemid
itemprop
itemref
itemscope
itemtype
lang
part
slot
spellcheck
style
tabindex
title
translate
For a full explanation of these attributes, see HTML 5 global attributes.
Event Handlers
Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.
onabort
onauxclick
onblur
oncancel
oncanplay
oncanplaythrough
onchange
onclick
onclose
oncontextmenu
oncopy
oncuechange
oncut
ondblclick
ondrag
ondragend
ondragenter
ondragexit
ondragleave
ondragover
ondragstart
ondrop
ondurationchange
onemptied
onended
onerror
onfocus
onformdata
oninput
oninvalid
onkeydown
onkeypress
onkeyup
onlanguagechange
onload
onloadeddata
onloadedmetadata
onloadstart
onmousedown
onmouseenter
onmouseleave
onmousemove
onmouseout
onmouseover
onmouseup
onpaste
onpause
onplay
onplaying
onprogress
onratechange
onreset
onresize
onscroll
onsecuritypolicyviolation
onseeked
onseeking
onselect
onslotchange
onstalled
onsubmit
onsuspend
ontimeupdate
ontoggle
onvolumechange
onwaiting
onwheel
Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.
For more detail, see HTML event handler content attributes.