What the browser actually does with an <hr>

The user-agent default for <hr> is stranger than it gets credit for. What the browser applies is essentially this:

border-style: inset;
border-width: 1px;

The default border-color is black, yet the line never reads as black. The inset border introduces a split tone that makes the element look slightly depressed rather than drawn as a flat rule.

Raising border-width to 40px exposes the construction plainly:

Clearing the default styling

Resetting an <hr> to "just a line" is a recurring gotcha. Trying height: 1px with a background does not produce the expected result, because the borders are still in play. The simpler route is to remove every border and then set only one of them:

  • Zero out all borders, then apply only border-top or only border-bottom.
  • Or zero out all borders, set a height, and use a background instead.

Inline SVG and the ARIA separator

Sara Soueidan's site design carries some of the nicest horizontal rules around, and she has documented the approach. The separators there are not <hr> elements at all. CSS turned out to be the only styling hook an <hr> offers, and it was not as adaptive as the design required, so the implementation settled on a <div role="separator"> containing inline SVG.

The best way to get the full flexibility of an SVG is by inlining it. But the <hr> element is content-less — it has no opening and closing tags within which you can place other elements.

The only way to work around the limitations of <hr> while preserving semantics for screen reader users is to use a div and provide the semantics of an hr using ARIA.