Horizontal Rules and Thematic Breaks
What you'll learn: How to use the <hr> element to visually separate different topics or sections within your content.
What Is a Horizontal Rule?
The <hr> element (which stands for "horizontal rule") creates a visible line across your page that signals a thematic break in your content. Think of it like the transition between scenes in a movie, or the asterisks (***) you sometimes see between sections in a novel—it tells readers "we're shifting to a different topic or scene now."
Unlike a simple visual decoration, <hr> carries semantic meaning. It's not just a line; it's telling browsers and assistive technologies that the content before and after are separate themes.
When to Use <hr>
Use <hr> when you need to separate content that shifts in theme or topic within the same section. For example:
- Between different scenes in a story
- Before and after a change of topic in a blog post
- Between a product description and customer reviews
The Basic Syntax
<p>This paragraph discusses the history of web development.</p>
<hr>
<p>Now let's shift gears and talk about modern frameworks.</p>
The <hr> element is self-closing (you don't need </hr>), similar to <img> and <br>. By default, browsers display it as a thin horizontal line.
Not Just a Visual Border
Remember: <hr> is semantic, not decorative. If you just want a visual line for styling purposes, use CSS borders instead. Use <hr> only when there's a meaningful thematic shift in your content.
Key Takeaway: The <hr> element creates a horizontal line that represents a thematic break between content sections, carrying semantic meaning beyond just visual separation.