HTML <hr> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Flow Content

What You’ll Learn

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.

01

Void Element

<hr> has no closing tag.

02

Thematic Break

Semantic topic shift between paragraphs.

03

CSS Styling

Border, color, dashed, and spacing.

04

Section Separation

Divide blocks of related content.

05

hr vs br

Topic break vs line break.

06

Accessibility

When hr adds meaning vs decoration.

What Is the <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.

💡
More than a line

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.

📝 Syntax

Insert <hr> where you want a thematic break between blocks of content:

syntax.html
<p>First topic paragraph.</p>

<hr>

<p>Second topic paragraph.</p>

Syntax Rules

  • hr is a void element — no closing tag in HTML.
  • XHTML-style <hr /> is also valid but optional in HTML5.
  • Place between flow content (paragraphs, sections) where a topic shift occurs.
  • Style with CSS classes — avoid obsolete presentational attributes.

⚡ Quick Reference

PatternCode SnippetNotes
Basic hr<hr>Default browser line
Styled with CSS<hr class="divider">Modern approach
Thick lineborder-top: 3px solid #1d4ed8CSS on hr element
Dashed breakborder-top-style: dashedVisual variant
Semantic roleThematic breakHTML5 meaning
Element typeVoid (self-closing)No children

⚖️ <hr> vs <br>

Both affect layout but serve different purposes:

Feature<hr><br>
PurposeThematic break between blocksLine break within text
Visual resultHorizontal rule lineNew line, no rule
Semantic meaningTopic/scene shiftSoft line wrap only
Typical placementBetween paragraphs or sectionsInside addresses, poems, lines

⚖️ <hr> vs CSS border

When to use each approach:

Feature<hr>CSS border on div
Semantic HTMLYes — thematic breakPurely presentational
Best forTopic shifts in proseCard dividers, UI chrome
AccessibilityAnnounced as separator in some ATIgnored unless labeled
FlexibilityStyled via CSS on hrFull layout control

🧰 Attributes

Modern HTML uses CSS instead of presentational attributes on hr:

class / id Global

Hook for CSS styling — the recommended way to customize appearance.

class="section-divider"
style Inline

Inline CSS works but prefer external stylesheets or classes in production.

style="border-color: #333"
align, size, width Obsolete

Legacy presentational attributes. Do not use in new HTML5 documents.

size="2" <!-- obsolete -->
noshade Obsolete

Historical boolean attribute for 3D bevel effect. Replaced by CSS.

noshade <!-- obsolete -->
attributes.html
<!-- Modern: use CSS class -->

<hr class="custom-divider">



<!-- CSS -->

.custom-divider {

  border: none;

  border-top: 2px solid #334155;

  margin: 1.25rem 0;

}

Examples Gallery

Basic horizontal rules, section separation, thematic breaks, and CSS styling with live previews.

Live Preview

Default and styled horizontal rules:

Content above the rule.


Default subtle divider.


Thick blue divider.


Dashed thematic break.

Styled Horizontal Rule

Customize the line with CSS border properties instead of obsolete HTML attributes.

styled-hr.html
<hr class="custom">



<!-- CSS -->

hr.custom {

  border: none;

  border-top: 3px solid #1d4ed8;

  margin: 1.25rem 0;

}
Try It Yourself

📚 Common Use Cases

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.

Section Separation

Visually separate different sections of a page with horizontal rules between content blocks.

section-separation.html
<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>
Try It Yourself

Thematic Break

Use hr to indicate a shift in topics within flowing prose content.

thematic-break.html
<p>Introduction to a topic...</p>

<hr>

<p>Exploring the main points...</p>
Try It Yourself

Styling <hr> with CSS

Modern browsers style hr with borders. Reset defaults and apply custom lines:

border-top Line thickness & color
margin Vertical spacing
dashed Border style variants
border: none Reset default bevel
hr-styles.css
hr {

  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

♿ Accessibility

Use hr thoughtfully for semantic breaks:

  • Use for thematic shifts — when content genuinely changes topic, not for every visual divider.
  • Do not overuse — too many horizontal rules create noise for screen reader users.
  • Prefer headings for structure — use h2 and section when organizing major page regions.
  • Pure decoration — use CSS borders on containers instead of empty semantic breaks.

🧠 How <hr> Works

1

Author inserts hr

Place hr between paragraph-level content at a topic shift.

Markup
2

Browser renders a line

Default user-agent styles draw a horizontal rule; CSS overrides appearance.

Rendering
3

Semantics signal a break

HTML5 defines hr as a thematic break, not just decoration.

Meaning
=

Clearer content flow

Readers see and understand where one topic ends and another begins.

Universal Browser Support

The <hr> element is a core HTML tag supported in every browser.

Baseline · Core HTML

Horizontal rules everywhere

hr has been supported since the earliest HTML versions. All modern and legacy browsers render it reliably.

100% Core tag support
Google Chrome All versions
Full support
Mozilla Firefox All versions
Full support
Apple Safari All versions
Full support
Microsoft Edge All versions
Full support
Internet Explorer All versions
Full support
Opera All versions
Full support
<hr> tag 100% supported

Bottom line: Use hr with confidence. Style it with CSS for consistent cross-browser appearance.

Conclusion

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.

💡 Best Practices

✅ Do

  • Use hr for genuine thematic breaks in prose
  • Style with CSS border and margin
  • Add vertical spacing before and after the rule
  • Use section + headings for major page structure

❌ Don’t

  • Confuse hr with br (line break)
  • Use obsolete attributes (size, width, noshade)
  • Overuse hr for every minor visual gap
  • Rely on inline color/height hacks instead of CSS classes

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <hr>

Bookmark these before you ship — they keep your separators semantic and styled consistently.

6
Core concepts
📚 02

Thematic Break

HTML5 semantic meaning.

Semantics
🎨 03

CSS Styling

Border and margin control.

Design
04

Not br

Block break, not line break.

Comparison
05

Use Sparingly

Meaningful breaks only.

Accessibility
🌐 06

100% Supported

Core HTML everywhere.

Compatibility

❓ Frequently Asked Questions

It represents a thematic break between paragraph-level content, rendered as a horizontal rule.
Yes. hr 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.
Use CSS border-top, margin, and border-color. Reset with border: none first for consistent results.
Prefer CSS borders for pure decoration. Use hr when the break carries semantic meaning as a topic shift.
Yes. hr is universally supported in every browser.

Style Horizontal Rules

Practice themed dividers and section breaks in the interactive HTML editor.

Try styled hr →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful