Explain it simply
Explain it simply
When you write an address on an envelope, the name, street and city each go on their own line. Those breaks are part of the address; without them it is hard to read. In HTML that kind of line break is written <br>. It is not a new paragraph, just a new line inside the same one.
<hr> is like the three stars (* * *) in a novel that tell you the scene has changed. It marks a shift of topic, and the browser draws it as a horizontal line.
Problem → Why → Solution
The problem: drawing layout with <br> and <hr>
The author of the page below added an <hr> under every heading for a decorative line, and four or five <br> tags between sections for spacing. The item list is separated with <br> as well. On a laptop it looks acceptable, but on a phone the gaps are huge, and changing the design means editing every HTML file.
<h2>Drinks</h2>
<hr>
<p>Green tea<br>Milk tea<br>Lime juice</p>
<br><br><br><br>
<h2>Snacks</h2>
<hr>
<p>Samosa<br>Spring roll</p>Why is this a problem?
<hr> carries the meaning "separator", so some screen readers announce a separator after every heading, claiming a topic change that never happened. A pile of <br> tags measures space in lines of text, which you cannot control when the screen size or font size changes. Items split with <br> are no longer a list, so assistive technology cannot tell how many items there are.
Core concept: breaks in content versus space for looks
Both <br> and <hr> are void elements: they have no content and therefore no closing tag. Writing <br/> with a slash also works in HTML, but the slash has no effect, while </br> is simply wrong. As earlier lessons showed, the browser collapses newlines in your source into spaces, so a real line break inside text needs <br>.
The question to ask before using <br> is: "if I removed this line break, would the content lose meaning?" For an address, a poem or song lyrics the answer is yes, so <br> is right. For space between paragraphs or sections the content does not change; that is presentation, so it is CSS margin. A list of items is a <ul>.
The HTML spec calls <hr> a paragraph-level thematic break: a scene change in a story, or a move from one subject to another within an article. It has the separator role in the accessibility tree, so some screen readers announce it. A new heading already signals a new topic, so you do not need an <hr> before headings. <hr> is a block element and cannot go inside <p>; place it between paragraphs.
By default the browser draws <hr> as a line with an inset border. CSS border, colour and margin can restyle it completely. When you only want a decorative line, skip <hr> and add a CSS property such as border-bottom to an element that already exists.
Screen readers usually do not announce a <br> at all; the lines are simply read one after another. That is fine for an address, but it also means <br> can never stand in for structure such as list items or paragraphs.
- Would removing it lose meaning?
- Yes, a line in text: <br>
- Yes, the topic shifts: <hr>
- No: it is CSS margin or border
<br> and <hr> are part of the content, not a ruler for drawing layout.
General pattern
<p>
First line of an address or poem<br>
Second line<br>
Third line
</p>
<p>The last paragraph about one topic.</p>
<hr>
<p>The first paragraph about the next topic.</p><br> goes wherever a line should end inside the paragraph, and is not needed after the last line. <hr> sits between two paragraphs to show the topic shift. Neither has a closing tag.
Example: an address and a change of topic
This page splits a three-line address with <br>, then places an <hr> before a new topic, opening hours. The last paragraph is a tiny demo that turns one source line into two lines with <br>.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Visit us</title>
</head>
<body>
<h1>Visit us</h1>
<p>
Golden Leaf Tea House<br>
12 Bogyoke Road<br>
Yangon
</p>
<hr>
<p>We are open every day from 7 am to 6 pm.</p>
<p>This is the first line.<br>This is the second line.</p>
</body>
</html>Code breakdown
- Lines 9-13
<p> Golden Leaf Tea House<br> 12 Bogyoke Road<br> Yangon </p>The whole address is one paragraph. The source newlines would only become spaces, so the two <br> tags are what break the lines. No <br> is needed after "Yangon"; </p> already ends the paragraph.
- Line 14
<hr>Marks the shift from the address to the opening hours. It sits between two paragraphs, not inside one, and has no closing tag.
- Line 15
<p>We are open every day from 7 am to 6 pm.</p>The space between the <hr> and this paragraph comes from the browser's default margins, not from extra <br> tags.
- Line 16
<p>This is the first line.<br>This is the second line.</p>Written on one source line, yet it shows as two lines because of <br>. Tags decide where lines break, not the layout of your source.
The address appears on three separate lines, followed by a thin grey line across the page, then the opening-hours paragraph, and finally "This is the first line." and "This is the second line." on two lines of one paragraph.Where CSS replaces <br> and <hr>
| What you want | What to use |
|---|---|
| Space between sections | CSS margin |
| A decorative line under a heading | CSS border-bottom |
| A list of items | <ul> with <li> |
| Lines of an address or poem | <br> |
| A change of topic | <hr>, styled with CSS |
The code below rewrites the menu from the problem section. The line under each heading is a CSS border, the space between sections is margin, and the items are a list. Changing the design now means editing two CSS rules.
<style>
h2 { border-bottom: 2px solid #c8a24a; padding-bottom: 4px; }
section { margin-bottom: 2.5rem; }
hr { border: 0; border-top: 1px dashed #999; margin: 2rem 0; }
</style>
<section>
<h2>Drinks</h2>
<ul><li>Green tea</li><li>Milk tea</li><li>Lime juice</li></ul>
</section>
<section>
<h2>Snacks</h2>
<ul><li>Samosa</li><li>Spring roll</li></ul>
</section>The hr rule in this code is ready for when a real <hr> appears, for example between the menu and an article about the shop. border: 0 removes the default inset border, and border-top draws a single clean line.
In real projects
Where this shows up in real projects
Website footers often show the company address with <br> between its lines. Lyrics sites and poetry blogs put each stanza in a <p> and separate its lines with <br>. Email signatures commonly split the name, job title and phone number with <br> too.
<hr> shows up in long articles at a change of subject, on fiction sites at a scene change, and wherever Markdown authors type --- (Markdown turns it into <hr>). Teams with a design system style hr once in CSS so it looks the same across the site, and draw lines between cards or under headings with the component's CSS border instead. In code review, consecutive <br><br> tags usually earn a comment asking for margin instead.
Common mistakes
Common mistakes
1. Stacking <br> tags for space
<br><br><br> measures space in lines, so it changes with the font size and cannot be tuned per screen. Use CSS margin-top or margin-bottom on the element instead.
2. Using <hr> as decoration
An <hr> under every heading creates separators where no topic changes, and screen reader users hear them for nothing. Put a border-bottom on the heading instead.
3. Building a list out of <br>
"Green tea<br>Milk tea<br>Lime juice" looks like a list, but a screen reader cannot say there are three items, and styling bullets is awkward. Use <ul> and <li>.
4. Putting <hr> inside a paragraph
<hr> is a block element, so the parser closes the paragraph there and creates an extra empty one. Place <hr> between paragraphs.
Best practices
Best practices
- In code review, apply the removal test to every <br>: does removing it break the content, or only change the layout?
- Define the look of hr once in a site-wide CSS rule rather than with a style attribute on each <hr>.
- Give each stanza or address block its own <p>; never create the gap between groups with a double <br>.
Mini challenge
Mini challenge: a poem page
Write a short two-stanza poem as a page. After the poem, change topic to an author's note. All spacing and decoration must come from CSS.
- Each stanza is one <p>, with <br> between its lines
- One <hr> between the poem and the author's note
- A line under the title drawn with a CSS border, not an hr
- Style the <hr> with CSS; no consecutive <br> tags
<!-- Place inside the <body> of a full page -->
<style>
/* TODO: a border under the h1 */
/* TODO: restyle hr (remove the default border, draw your own) */
</style>
<!-- TODO: h1 with the poem title -->
<!-- TODO: stanza 1 - one paragraph, lines separated by <br> -->
<!-- TODO: stanza 2 -->
<!-- TODO: a thematic break, then the author's note paragraph -->Expected: A CSS line under the title, two four-line stanzas separated by space, then one custom-styled <hr> and the author's note.
Show hint
Put <br> at the end of each line except the last line of a stanza, where </p> goes instead. The space between stanzas comes from the paragraph margin.
Show solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Monsoon Morning</title>
<style>
h1 { border-bottom: 2px solid #4a7c59; padding-bottom: 6px; }
hr { border: 0; border-top: 1px dotted #888; margin: 2rem 0; }
</style>
</head>
<body>
<h1>Monsoon Morning</h1>
<p>
Rain taps the tin roof,<br>
the street turns into a river,<br>
a vendor shouts "tea!"<br>
and the city wakes up wet.
</p>
<p>
By noon the clouds move on,<br>
puddles hold a piece of sky,<br>
children race paper boats<br>
down the shining gutter.
</p>
<hr>
<p>Author's note: I wrote this poem during my first rainy season in Yangon.</p>
</body>
</html>Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- Use <br> only where the line break is content, as in an address or a poem.
- <hr> is a thematic break for a change of topic, not a decorative line.
- Use margin for space, border for decorative lines and <ul> for lists.
- Both are void elements with no closing tag.
HTML Living Standard — WHATWG