What is the <hr> tag?
The <hr> tag adds a horizontal line to a web page. It's used to separate sections of content, such as a change of topic in an article or a break between two parts of a story.
Officially, <hr> represents a thematic break: a shift from one idea to the next. Screen readers (software that reads pages aloud) announce it as a "separator", so it carries meaning, not just decoration.
On its own, though, the default line is rather plain:
In this post we'll look at 14 ways to give it more style with CSS, from simple dotted lines to gradients, glows and symbols.
Getting started: a blank canvas
Browsers draw the default <hr> using borders, usually a 1px grey border with a slightly sunken look. Before adding your own style, it's best to remove those with the border property:
hr {
border: 0;
}
That gives you a blank canvas: an empty, full-width block you can style however you like. Every example below starts this way.
You may also want to set the space above and below the line. Browsers add a small margin by default; something more generous often looks better:
hr {
border: 0;
margin-block: 2rem; /* space above and below */
}
Tip: the examples below use a class on each hr, such as hr.dotted, so you can mix several styles on one page. To style every <hr> on your site the same way, just use hr as the selector.
Simple border lines
1. Etched line
A dark line with a light line beneath it, which looks carved into the page. It works best on a light grey background.
hr.etched {
border: 0;
border-top: 1px solid #9ca3af;
border-bottom: 1px solid #ffffff;
}
2. Dotted line
The simplest change: swap solid for dotted.
hr.dotted {
border: 0;
border-top: 3px dotted #6b7280;
}
3. Dashed line
Or use dashed for short dashes.
hr.dashed {
border: 0;
border-top: 2px dashed #6b7280;
}
4. Two-colour dashed line
A dashed border over a solid background. The background shows through the gaps between the dashes, giving two alternating colours.
hr.twotone {
border: 0;
border-top: 3px dashed #1d4ed8;
background: #fbbf24;
height: 0;
}
5. Double line
double draws two thin lines. The border needs to be at least 3px wide to leave room for both lines and the gap between.
hr.double {
border: 0;
border-top: 4px double #6b7280;
}
Tip: leave the colour out of the border, as in border-top: 2px dashed, and set color on the hr instead. Borders use the text colour by default, so one color property then controls the whole line.
Gradient and shadow lines
6. Fading gradient line
A line that fades in from the edges, strongest in the middle. The gradient runs from fully transparent to grey and back.
hr.fade {
border: 0;
height: 1px;
background: linear-gradient(to right, transparent, #4b5563, transparent);
}
7. Colourful gradient line
Gradients can use any colours. A thicker line with rounded ends makes a bold divider.
hr.colour {
border: 0;
height: 4px;
border-radius: 999px;
background: linear-gradient(to right, #1d4ed8, #7c3aed, #db2777);
}
8. Soft shadow line
An inner shadow that fades downwards, like the edge of a sheet of paper.
hr.shadow {
border: 0;
height: 12px;
box-shadow: inset 0 12px 12px -12px rgb(0 0 0 / 0.5);
}
9. Glowing line
A thin, pale line surrounded by a blurred, coloured box-shadow, which gives a neon glow.
hr.glow {
border: 0;
height: 2px;
background: #93c5fd;
box-shadow: 0 0 10px 2px #3b82f6;
}
Correction: the original version of example 7 used linear-gradient(left, ...). That was an old, browser-prefixed way of writing the direction, and without a prefix, modern browsers ignore the whole value, so the line didn't appear at all. The standard way is to right or to left.
Decorative lines
10. Arched line
A border on top only, with a large elliptical border-radius, curves into a gentle arch.
hr.arch {
border: 0;
height: 16px;
border-top: 2px solid #6b7280;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
11. Section sign in the middle
Two short lines are painted as background images, leaving a gap in the middle for a symbol added with ::after.
hr.section {
display: grid;
place-items: center;
height: 1.5em;
border: 0;
color: #6b7280;
background:
linear-gradient(currentColor 0 0) left center / calc(50% - 1.25em) 1px no-repeat,
linear-gradient(currentColor 0 0) right center / calc(50% - 1.25em) 1px no-repeat;
}
hr.section::after {
content: "\00A7"; /* § */
font-size: 1.25em;
line-height: 1;
}
12. Heart on a double line
The same technique with a double line. The gradient draws a 1px line, a 2px gap and another 1px line.
hr.heart {
display: grid;
place-items: center;
height: 1.5em;
border: 0;
color: #be185d;
--line: linear-gradient(currentColor 0 1px, transparent 1px 3px, currentColor 3px 4px);
background:
var(--line) left center / calc(50% - 1.25em) 4px no-repeat,
var(--line) right center / calc(50% - 1.25em) 4px no-repeat;
}
hr.heart::after {
content: "\2665"; /* ♥ */
font-size: 1.1em;
line-height: 1;
}
13. "Cut here" line
A dashed line made with repeating-linear-gradient, with a pair of scissors at the start. Great for coupons.
hr.cut {
display: grid;
align-items: center;
justify-items: start;
height: 1.5em;
border: 0;
color: #4b5563;
background: repeating-linear-gradient(to right, currentColor 0 6px, transparent 6px 11px)
right center / calc(100% - 1.75em) 1px no-repeat;
}
hr.cut::after {
content: "\2702\FE0E"; /* ✂ */
font-size: 1.2em;
line-height: 1;
}
14. Zig-zag edge
A conic-gradient draws one triangle, and repeating it across the line creates a zig-zag edge.
hr.zigzag {
border: 0;
height: 10px;
background: conic-gradient(from 135deg at top, #6b7280 90deg, transparent 0)
top left / 14px 10px repeat-x;
}
What changed since the old version? The original symbol lines drew one long line, then hid the middle of it by giving the symbol a white background. On any other background colour, a white box appeared around the symbol. Painting two shorter lines with a gap, as above, works on any background, including dark mode.
Tips for using dividers
Use <hr> for real breaks in content
Because screen readers announce <hr> as a separator, use it where the content genuinely changes direction. For purely decorative lines, such as a line under every heading or around a card, use a CSS border on that element instead. That way visitors using screen readers don't hear "separator" over and over.
Make sure it can be seen
Very pale lines can disappear on some screens or in bright sunlight. If the divider helps people understand the structure of your page, give it enough contrast against the background to be clearly visible.
Think about dark mode
Fixed colours like #333 can vanish on a dark background. Using currentColor, the text colour, keeps your line visible whatever the theme. Several examples above already do this.
Symbols and emoji
Some symbols, like the scissors in example 13, can appear as colourful emoji on certain devices. Adding \FE0E after the character, as in content: "\2702\FE0E", asks the browser to show the plain text version instead.
Wrapping up
A horizontal line is a small detail, but a well-styled one can tie a design together. Start with border: 0, then use borders, gradients, shadows or pseudo-elements to create the look you want. Have a great <hr> design of your own? Contact us with the code, and we may add it to the list.