# How to Style an hr (Horizontal Rule) in CSS

DevFeed: [How to Style an hr (Horizontal Rule) in CSS](<https://devfeed.tech/articles/how-to-style-an-hr-horizontal-rule-in-css-121396.md>)

Original publisher: [Read original article](<https://markodenic.com/css-hr/>)

Author: Marko

Published: 2026-11-06T09:00:00Z

Content type: tutorial

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [CSS Resets](<https://devfeed.tech/topics/css-reset.md>)

Tags: [border](<https://devfeed.tech/tags/border.md>), [color](<https://devfeed.tech/tags/color.md>), [css](<https://devfeed.tech/tags/css.md>), [gradient](<https://devfeed.tech/tags/gradient.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [hr](<https://devfeed.tech/tags/hr.md>), [html](<https://devfeed.tech/tags/html.md>), [screen-readers](<https://devfeed.tech/tags/screen-readers.md>), [semantic](<https://devfeed.tech/tags/semantic.md>), [style](<https://devfeed.tech/tags/style.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

The excerpt's key fix is to remove the browser's default border before styling <hr>; setting color or background alone may not change its appearance consistently. From there, use a border for line color and thickness, or a height and background for rounded, gradient, or custom dashed lines. A repeating-linear-gradient controls dash and gap lengths, while width plus auto side margins creates a shorter centered rule. For text between two lines, the excerpt recommends a flex container with pseudo-elements because <hr> cannot contain text; an ornament can instead be added to a real <hr> with ::after. Semantically, <hr> marks a thematic break announced as a separator by screen readers. Use a CSS border for purely decorative dividers.

## Source excerpt

Style the HTML hr element with CSS: change its color and thickness, make dashed, dotted and gradient lines, add text or an icon in the middle, and use it correctly as a thematic break.