hr

The HTML <hr> element marks a thematic break between parts of a document. It is not just a request to draw a decorative horizontal line.

What you will learn

Basic syntax

<h2>Ingredients</h2>
<p>Prepare the ingredients first.</p>

<hr>

<h2>Method</h2>
<p>Follow these steps to prepare the dish.</p>

hr is a void element. It has no closing tag and no child content. Place it where the topic or scene changes, not merely wherever a visual gap is convenient.

hr is about meaning

Use hr when the surrounding content remains one larger piece but its topics or scenes are divided. For a new independent article or a new major section, a heading or a structural element may communicate the relationship better.

Style it with CSS

hr {
  border: 0;
  border-top: 1px solid currentColor;
  opacity: 0.35;
  margin-block: 2rem;
}

Keep the HTML choice based on meaning and use CSS for color, thickness, spacing, or other visual treatment. Do not use an empty element or a row of hyphens just to create a line.

Common mistakes

Related pages