Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #204

Horizontal Rule (hr)

The <hr> tag represents a thematic break — a shift to a new topic or scene. Browsers draw it as a horizontal line by default, but that line is just styling; the real meaning is "something changed here."

Syntax

<hr>

Basic Example

<p>...end of the chapter on HTML basics.</p>
<hr>
<p>Next: an introduction to CSS.</p>

Browser output: a plain horizontal line spanning the width of its container, sitting between the two paragraphs, with default margin above and below.

How It Works

  1. <hr> is a void element — like <br>, it has no closing tag and no content.
  2. The browser renders a default horizontal line via its built-in stylesheet, but you can restyle it completely with CSS border/height — the visual line is not what makes it meaningful.

Important Attributes

AttributePurpose
— none in HTML5 —Older presentational attributes like size, width, and noshade are obsolete; use CSS instead

Real-World Example

<article>
    <p>That wraps up the basics of Python syntax.</p>
    <hr>
    <p>Now let's move on to a completely different topic: working with files.</p>
</article>

A genuine change of subject inside one long article — not just "I want a line here for decoration."

Common Mistakes

  • Using <hr> purely as a decorative divider line with no actual change in topic — that's a styling choice, not a structural one; a plain <div> with a CSS border is more honest
  • Using deprecated presentational attributes like <hr size="2" noshade> instead of CSS to control appearance

Best Practices

  • Reserve <hr> for genuine topic or scene shifts within content
  • Style its appearance entirely with CSS — never rely on default browser styling for anything visually important

Accessibility Considerations

Screen readers announce <hr> as a separator, giving users a clear "the topic has changed" cue that a purely decorative line (styled with CSS on a <div>) would never provide.

SEO Considerations

Minor at best — it can help signal content segmentation within a long page, but it's not a meaningful ranking factor on its own.

Browser & Modern HTML Notes

HTML5 redefined <hr> from a purely presentational divider into a semantic thematic-break element, and dropped its old presentational attributes in favor of CSS.

Mini Practice

  1. Add an <hr> between two genuinely different topics in a sample article.
  2. Restyle an <hr> with CSS to be a thick, colored line instead of the default thin gray one.

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →