/ factorpad.com / tech / html5 / reference / html-br-tag.html
An ad-free and cookie-free website.
Beginner
The <br />
tag's primary purpose
is to add a line break within a block of text.
The <br />
tag only occurs in the
<body>
, so the visible section of
the document. From there it is normally found within a paragraph, so
in a <p>
element.
Its purpose is to add a carriage return, which is also called a line
break or new line across programming languages. You might
require a break when writing a poem or a mailing address, although the
<address>
element might be a
better option.
As an inline-element, a break can be placed anywhere on a line. It doesn't take up the whole space of its parent element as a block-level element would.
So the <br />
tag is about the
display of text, not document structure.
The <br />
element requires only
one tag. There are a handful of other single-tag elements, like
<meta />
,
<hr />
and
<img />
. These may also be
referred to as "empty tags".
Unlike other most other tags, the
<br />
tag has no attributes.
Of course global attributes apply, as they do with all elements.
Technically under HTML5, the tag can be input simply as
<br>
, but since it is so similar
to the XML and XHTML-conforming standard of
<br />
, I recommend learning the
longer form here, especially as you progress towards learning the more
advanced markup language XML, the eXtensible Markup Language.
The importance of XML has grown over recent years with the popularity of automated forms of web publishing like blogs and social feeds that connect to databases.
HTML code input above will appear as shown below.
Write Poetry. We Wish He Could.
If he could write a nice poem, :] |
As with all tags, Global Attributes can always be set.
The <br />
element doesn't
have any of its own attributes, or they would be detailed here.
Each user-agent (browser) has its own stylesheet per se. This dictates
how that browser styles each element by default. The Chrome browser
styles the <br />
element using
the following specifications.
The following HTML code will create line breaks for an address block.
Learning takes practice. Type these lines into a text file, save it with an .html extension and open it in a browser.
After that, start taking notes and writing in HTML to gain experience.
The <br />
tag sits in a
paragraph element, and that sits in the body element.
See what else you can learn for free at our YouTube Channel. If you want updates, follow @factorpad on Twitter.
<body>
tag, click Back.<div>
tag, click Next./ factorpad.com / tech / html5 / reference / html-br-tag.html
A newly-updated free resource. Connect and refer a friend today.