CSS / Reference / text-decoration: Decoration Propagation, Underlines, and Link Meaning
CSS text-decoration sets the line, style, color, and thickness of underlines, overlines, and strike-throughs in one declaration. Adjust the underline’s offset separately with text-underline-offset. To leave part of a sentence plain, apply the decoration only to the span that needs it.
Set the line, style, color, and thickness
underline, overline, and line-through select where the line is drawn. You can request multiple lines, such as underline overline. Line styles include solid, double, dotted, dashed, and wavy. See the CSS text-decoration shorthand specification for the shorthand syntax.
.wavy {
text-decoration: underline wavy #006c9c 2px;
text-underline-offset: .18em;
}
| Declaration value | Appearance | Preview |
|---|---|---|
underline wavy #006c9c 2px |
Blue wavy underline | |
overline solid #006c9c 2px |
Blue solid overline | |
line-through solid #006c9c 2px |
Blue solid strike-through | |
underline overline dotted #006c9c 2px |
Blue dotted underline and overline |
The longhands are text-decoration-line, text-decoration-style, text-decoration-color, and text-decoration-thickness. Omitting a value from the shorthand resets it to its initial value: none, solid, currentColor, or auto, respectively. Set just text-decoration-line to retain an existing color or thickness.
Run the line and link examples
Save the full document as a UTF-8 file named text-decoration-example.html and open it in a browser. Compare a wavy underline, two dotted lines, and a strike-through in the first section. It needs no external stylesheet.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Compare CSS text-decoration</title>
<style>
body { margin: 1rem; color: #20242b; background: #fff;
font: 1rem/1.65 system-ui, sans-serif; }
main { max-width: 44rem; margin-inline: auto; }
.sample { font-size: 1.2rem; }
.wavy { text-decoration: underline wavy #006c9c 2px;
text-underline-offset: .18em; }
.two-lines { text-decoration: underline overline dotted #006c9c 2px; }
.strike { text-decoration: line-through; }
.origin, .only { text-decoration: underline solid #aa3377 3px;
text-underline-offset: .16em; text-decoration-skip-ink: none; }
.child { text-decoration: none; }
.copy-link { color: #005879; text-decoration: underline solid currentColor;
text-underline-offset: .16em; }
.copy-link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
</style>
</head>
<body>
<main>
<h1>Compare CSS text-decoration</h1>
<h2>Line position and style</h2>
<p class="sample wavy">CSS decoration sample</p>
<p class="sample two-lines">CSS decoration sample</p>
<p class="sample strike">CSS decoration sample</p>
<h2>Parent decoration and scope</h2>
<p class="sample origin"><span>First span</span> <span class="child">Second span</span></p>
<p class="sample scoped"><span class="only">First span</span> <span class="plain">Second span</span></p>
<h2>Links and deleted content</h2>
<p><a class="copy-link" href="#details">See the changed schedule</a></p>
<p id="details"><del>Original schedule Monday</del> The new day is Tuesday.</p>
</main>
</body>
</html>
The first sentence in the second section has a purple underline beneath both spans. In the next sentence, only the first span is underlined. Press Tab to focus the link in the last section and see its underline and keyboard focus outline together.
See why a parent’s underline stays visible
The text decoration longhands do not inherit in the usual way. Instead, the parent’s underline can be drawn across the text of an inline child in the same flow. The child’s computed text-decoration-line can be none while the parent’s line is still visible. The CSS decoration propagation rules explains where that line is drawn.
Add text-decoration: none to .origin only. The first sentence loses its whole underline. Remove the declaration after the test. To underline only the desired words, apply the decoration to their span as the second sentence does. Scoping the line this way keeps the surrounding text in the same flow.
Keep links recognizable and mark deleted text
An underline helps readers recognize a link within prose. Keep a visible focus indicator for keyboard navigation. The rule below applies to links with the .copy-link class. See the WCAG use-of-color criterion and the guide to link states and keyboard focus for more on recognizing and focusing links.
.copy-link {
text-decoration: underline solid currentColor;
text-underline-offset: .16em;
}
.copy-link:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
Use <del> for content removed from a document. The example shows the canceled Monday schedule and states the new Tuesday schedule in words. CSS line-through provides the visual line. The deletion meaning comes from the <del> element defined in the HTML specification for del.
Diagnose an unwanted or crowded line
If a line remains visible, use developer tools to check text-decoration-line on the child and on the element that creates the line. If an underline is too close to the letters, adjust its thickness and text-underline-offset. That offset affects underlines. Use border-bottom to draw a border along the edge of a box.
If a line appears broken, check whether text-decoration-skip-ink: auto is skipping places where it meets the letters. The purple demo sets it to none so you can compare continuous lines. Check legibility with the actual font and line height. The guide to fonts and line height gives related settings.




