HTML hr Tag

Beginner
6 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <hr> element marks a thematic break between content — a change of scene, topic, or section within a page. Visual browsers usually show it as a horizontal line, but the meaning is semantic, not decorative.

Prefer <hr> when the break itself matters in the content. If you only need a drawn line with no topic change, add a CSS border to another element instead. Do not confuse it with <br> (a line break inside text).

Baseline · Widely available.

Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).

Deprecated attributes.

Do not use align, color, noshade, size, or width on <hr>. Style the rule with CSS borders instead.

HTML Syntax

syntax.html
<hr >

Void element: start tag only, no content, no end tag. Implicit ARIA role is separator.

Attributes

Modern <hr> has no element-specific attributes — only global attributes. Older presentational attributes below are obsolete.

AttributeDescriptionNotes
None specificNo modern dedicated attributes on <hr>.Use class / id with CSS for looks.
alignDeprecated — once set left/center/right alignmentUse CSS margin / width instead
colorDeprecated — once set the rule colorUse CSS border-color instead
noshadeDeprecated — once removed 3D shadingUse flat CSS borders instead
sizeDeprecated — once set height in pixelsUse CSS border-width / height
widthDeprecated — once set length in px or %Use CSS width instead

Global Attributes

The <hr> tag also supports the Global Attributes in HTML.

Live Preview

Switch CSS styles on the same thematic break — meaning stays the same; looks change.

Style with CSS borders — never with obsolete HTML attributes.

Preview

Topic A ends here.


Topic B begins here.

Default border-top line

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Thematic Break Between Paragraphs

Mark a topic shift between two blocks of text.

HTML
<p>Chapter 1 ends with a quiet scene.</p>
<hr>
<p>Chapter 2 opens in a busy market.</p>
Try It Yourself

How It Works

  1. Write the first topic in a block such as <p>.
  2. Insert <hr> where the topic or scene changes.
  3. Continue with the next topic after the break.
  4. Browsers draw a line by default; the important part is the thematic meaning.

Example 2 — Style the Rule with CSS

Keep semantic <hr>; change thickness and color with borders.

HTML
<style>
  hr.accent {
    border: none;
    border-top: 3px solid #1d4ed8;
    margin: 1rem 0;
  }
</style>

<p>Content above the rule.</p>
<hr class="accent">
<p>Content below the rule.</p>
Try It Yourself

How It Works

  1. Keep a plain <hr> for the thematic break.
  2. Add a class for the look you want.
  3. Reset default borders with border: none, then set border-top.
  4. Avoid obsolete attributes like color, size, and width.

Example 3 — Separator in a Menu List

Place <hr> inside a list item to split groups of actions.

HTML
<ul>
  <li>Cut</li>
  <li>Copy</li>
  <li>Paste</li>
  <li role="presentation"><hr></li>
  <li>Delete</li>
</ul>
Try It Yourself

How It Works

  1. List the main actions as normal <li> items.
  2. Add a separator item that contains only <hr>.
  3. Set role="presentation" on that <li> so it is not treated as a real list entry.
  4. Continue with the next group of actions after the break.

Example 4 — Separator Inside a Select

Use <hr> between options to group choices visually.

HTML
<label for="fruit">Choose a fruit</label>
<select id="fruit">
  <option value="">-- Choose --</option>
  <hr>
  <option value="apple">Apple</option>
  <option value="banana">Banana</option>
  <hr>
  <option value="mango">Mango</option>
  <option value="orange">Orange</option>
</select>
Try It Yourself

How It Works

  1. Build a normal <select> with <option> choices.
  2. Insert <hr> between option groups (allowed as a child of select).
  3. Open the control to see the visual gap between groups.
  4. Support varies slightly by browser, but the markup is valid HTML.

Edge Cases & Pitfalls

Most hr mistakes mix decoration with meaning, or revive obsolete attributes.

meaning

Not every line is an hr

If you only want a visual divider with no topic change, use a CSS border on another element instead of <hr>.

obsolete

Skip presentational attributes

align, color, noshade, size, and width are deprecated. Use CSS borders and width.

vs br

hr ≠ br

<br> breaks a line inside text. <hr> separates blocks with a thematic break.

void

No content or end tag

Do not write <hr>...</hr> or put text inside. Use <hr> alone.

a11y

Role is separator

Assistive tech may announce a separator. Prefer real topic changes so that announcement stays useful.

Browser Support

The <hr> element is core HTML flow content in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<hr>

Widely available since about July 2015 (and long before). Chrome, Firefox, Safari, Edge, and Opera all support thematic breaks with default horizontal-rule styling.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
hr Widely supported

Bottom line: Safe to use everywhere. Style with CSS; reserve hr for real thematic breaks.

Key Takeaways

  • Meaning: hr marks a thematic break, not just a pretty line.
  • Style: use CSS borders; never obsolete align/color/size/width.
  • Void: write <hr> alone — no content, no end tag.
  • Compare: hr ≠ br; decoration alone ≠ thematic break.

One line: use hr for a real topic shift, then style the line with CSS.

Default CSS Settings

Typical user-agent defaults (exact values vary by browser):

default.css
hr {
  display: block;
  margin-block: 0.5em;
  border: none;
  border-top: 1px solid;
  color: gray;
}

Override with border, width, and margin as needed. Keep the HTML semantic.

Frequently Asked Questions

The hr element marks a thematic break — a shift of topic or scene. Browsers usually draw it as a horizontal line, but the meaning is semantic, not decorative.
Yes. Write <hr> or <hr />. There is no end tag and no content inside.
No. Those presentational attributes are obsolete. Style the rule with CSS border properties instead.
If you only want a visual line with no topic change, put a border on another element. Use hr when the break itself is meaningful in the content.
br inserts a line break inside text. hr separates blocks of content with a thematic break. They solve different problems.
The implicit ARIA role is separator. Assistive tech can announce a separation between regions of content.

Next: html

Wrap the whole document with the root HTML html element.

html tutorial →

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.

12 people found this page helpful