Using br To Insert Line Breaks In HTML: Here's How
- Element of
- Learn How Fonts And Web Typography Work In HTML: A Beginner's Guide
- What does
Using br To Insert Line Breaks In HTML: Here's How
do? - The <br> element is used to insert a line break or carriage-return within a parent element such as a paragraph without breaking out of the parent container.
- Display
- inline
- Usage
- textual
Code Example
This sentence and the next will be on different lines.<br>This sentence and the one before will be on different lines.
This sentence and the one before will be on different lines.
Don’t abuse line breaks
The <br>
element creates a line break. It can be easy to abuse this element to create styling which that mimics better, more semantic options like paragraphs ( <p>
) and lists. Generally, the <br>
element should only be used if the line break itself is an intrinsic part of the content. This might be the case, for example, with:
- addresses
- poetry
- code samples
John Smith<br> c/o Jane Smythe<br> 123 Main St.<br> Northeast Southwestershire, XY 12345
c/o Jane Smythe
123 Main St.
Northeast Southwestershire, XY 12345
<blockquote> <p>Out of the night that covers me,<br> Black as the pit from pole to pole,<br> I thank whatever gods may be<br> For my unconquerable soul.</p> <p>In the fell clutch of circumstance<br> I have not winced nor cried aloud.<br> Under the bludgeonings of chance<br> My head is bloody, but unbowed.</p> <p>Beyond this place of wrath and tears<br> Looms but the Horror of the shade,<br> And yet the menace of the years<br> Finds, and shall find me, unafraid.</p> <p>It matters not how strait the gate,<br> How charged with punishments the scroll,<br> I am the master of my fate:<br> I am the captain of my soul.</p> — <cite>Invictus</cite>, by William Ernest Henley </blockquote>
Out of the night that covers me,
Black as the pit from pole to pole,
I thank whatever gods may be
For my unconquerable soul. In the fell clutch of circumstance
I have not winced nor cried aloud.
Under the bludgeonings of chance
My head is bloody, but unbowed. Beyond this place of wrath and tears
Looms but the Horror of the shade,
And yet the menace of the years
Finds, and shall find me, unafraid. It matters not how strait the gate,
How charged with punishments the scroll,
I am the master of my fate:
I am the captain of my soul.— Invictus, by William Ernest Henley
If you find yourself using <br>
to separate blocks of texts, you may need to think about using paragraph tags or another element. If you are using them to create more space between items, you should use CSS margin
.
Browser Support for br
All | All | All | All | All | All |