Live Preview
Default and styled horizontal rules:
Content above the rule.
Default subtle divider.
Thick blue divider.
Dashed thematic break.

By the end of this tutorial, you’ll use <hr> correctly for thematic breaks and style horizontal rules with modern CSS.
The HTML <hr> tag creates a horizontal rule that separates content. In HTML5 it represents a thematic break — not just a decorative line.
<hr> has no closing tag.
Semantic topic shift between paragraphs.
Border, color, dashed, and spacing.
Divide blocks of related content.
Topic break vs line break.
When hr adds meaning vs decoration.
<hr> Tag?The horizontal rule element (<hr>) produces a line across the page and indicates a thematic break between paragraph-level elements. Browsers render it as a horizontal divider by default, but its HTML5 meaning is semantic: a shift in topic or scene.
In HTML5, hr is not merely a visual separator. It tells parsers and assistive technologies that the following content starts a new theme. For purely decorative dividers, CSS borders on containers are often better.
hr is a void element — it cannot contain text or child elements and does not use a closing tag in HTML syntax.
Insert <hr> where you want a thematic break between blocks of content:
<p>First topic paragraph.</p>
<hr>
<p>Second topic paragraph.</p>hr is a void element — no closing tag in HTML.<hr /> is also valid but optional in HTML5.| Pattern | Code Snippet | Notes |
|---|---|---|
| Basic hr | <hr> | Default browser line |
| Styled with CSS | <hr class="divider"> | Modern approach |
| Thick line | border-top: 3px solid #1d4ed8 | CSS on hr element |
| Dashed break | border-top-style: dashed | Visual variant |
| Semantic role | Thematic break | HTML5 meaning |
| Element type | Void (self-closing) | No children |
<hr> vs <br>Both affect layout but serve different purposes:
| Feature | <hr> | <br> |
|---|---|---|
| Purpose | Thematic break between blocks | Line break within text |
| Visual result | Horizontal rule line | New line, no rule |
| Semantic meaning | Topic/scene shift | Soft line wrap only |
| Typical placement | Between paragraphs or sections | Inside addresses, poems, lines |
<hr> vs CSS borderWhen to use each approach:
| Feature | <hr> | CSS border on div |
|---|---|---|
| Semantic HTML | Yes — thematic break | Purely presentational |
| Best for | Topic shifts in prose | Card dividers, UI chrome |
| Accessibility | Announced as separator in some AT | Ignored unless labeled |
| Flexibility | Styled via CSS on hr | Full layout control |
Modern HTML uses CSS instead of presentational attributes on hr:
class / id GlobalHook for CSS styling — the recommended way to customize appearance.
class="section-divider"style InlineInline CSS works but prefer external stylesheets or classes in production.
style="border-color: #333"align, size, width ObsoleteLegacy presentational attributes. Do not use in new HTML5 documents.
size="2" <!-- obsolete -->noshade ObsoleteHistorical boolean attribute for 3D bevel effect. Replaced by CSS.
noshade <!-- obsolete --><!-- Modern: use CSS class -->
<hr class="custom-divider">
<!-- CSS -->
.custom-divider {
border: none;
border-top: 2px solid #334155;
margin: 1.25rem 0;
}Basic horizontal rules, section separation, thematic breaks, and CSS styling with live previews.
Default and styled horizontal rules:
Content above the rule.
Default subtle divider.
Thick blue divider.
Dashed thematic break.
Customize the line with CSS border properties instead of obsolete HTML attributes.
<hr class="custom">
<!-- CSS -->
hr.custom {
border: none;
border-top: 3px solid #1d4ed8;
margin: 1.25rem 0;
}Use <hr> to separate article sections, mark scene changes in stories, divide FAQ answers, split footer columns visually, or indicate a shift from introduction to main discussion. Prefer semantic section elements with headings when structure matters more than a simple break.
Visually separate different sections of a page with horizontal rules between content blocks.
<section>
<h2>Section 1</h2>
<p>Content for section 1...</p>
<hr>
</section>
<section>
<h2>Section 2</h2>
<p>Content for section 2...</p>
</section>Use hr to indicate a shift in topics within flowing prose content.
<p>Introduction to a topic...</p>
<hr>
<p>Exploring the main points...</p>Modern browsers style hr with borders. Reset defaults and apply custom lines:
border-top Line thickness & colormargin Vertical spacingdashed Border style variantsborder: none Reset default bevelhr {
border: none;
border-top: 1px solid #cbd5e1;
margin: 1.5rem 0;
}
hr.dashed {
border-top-style: dashed;
border-color: #94a3b8;
}
hr.accent {
border-top-width: 3px;
border-color: #1d4ed8;
}Live styled hr variants
Standard divider
Accent divider
Dashed break
Use hr thoughtfully for semantic breaks:
h2 and section when organizing major page regions.Place hr between paragraph-level content at a topic shift.
Default user-agent styles draw a horizontal rule; CSS overrides appearance.
HTML5 defines hr as a thematic break, not just decoration.
Readers see and understand where one topic ends and another begins.
The <hr> element is a core HTML tag supported in every browser.
hr has been supported since the earliest HTML versions. All modern and legacy browsers render it reliably.
Bottom line: Use hr with confidence. Style it with CSS for consistent cross-browser appearance.
The <hr> tag is a simple but meaningful tool for separating content. Use it for thematic breaks, style it with CSS, and avoid obsolete presentational attributes.
Combine hr with clear headings and sections for well-organized pages that are easy to read and navigate.
hr for genuine thematic breaks in proseborder and marginsection + headings for major page structurehr with br (line break)size, width, noshade)color/height hacks instead of CSS classes<hr>Bookmark these before you ship — they keep your separators semantic and styled consistently.
No closing tag needed.
SyntaxHTML5 semantic meaning.
SemanticsBorder and margin control.
DesignBlock break, not line break.
ComparisonMeaningful breaks only.
AccessibilityCore HTML everywhere.
Compatibilityhr is a void element with no closing tag in HTML syntax.hr separates topics with a horizontal line. br breaks to a new line within the same text block.border-top, margin, and border-color. Reset with border: none first for consistent results.hr when the break carries semantic meaning as a topic shift.hr is universally supported in every browser.Practice themed dividers and section breaks in the interactive HTML editor.
6 people found this page helpful