Text Decoration, Underline Offsets, Emphasis Marks and Text Shadows
Lines and marks on text: the text-decoration longhands, underline offset and position, skip-ink and the new text-decoration-inset, why decorations can't be removed from descendants, East Asian emphasis marks, and text-shadow for legibility and effects.
kvi5hnuCode Sprout team member6 min readOn this page
Underlines are the most recognizable signal on the web: they mean "this is a link". CSS gives detailed control over them, plus overlines, strike-throughs, the emphasis marks used in East Asian typography, and shadows behind text.
text-decoration
text-decoration is a shorthand for four properties:
| Longhand | Values |
|---|---|
text-decoration-line | none, underline, overline, line-through, or several: underline overline; also spelling-error and grammar-error |
text-decoration-style | solid, double, dotted, dashed, wavy |
text-decoration-color | any color; defaults to currentColor |
text-decoration-thickness | auto, from-font, or a length or percentage of 1em |
a { text-decoration: underline 1px; text-underline-offset: 0.2em; }
.error { text-decoration: underline wavy #c0392b 1.5px; }
del { text-decoration: line-through 2px; }
Tested in Chrome: text-decoration: underline wavy red 2px is valid and reads back as underline 2px wavy red, so the values can come in any order.
Shaping the underline

| Property | Effect |
|---|---|
text-underline-offset | distance from the underline's reference position: the baseline with the default text-underline-position: auto, the bottom of the text with under; use em so it scales with the text: 0.2em |
text-decoration-thickness | from-font uses the thickness the font designer chose |
text-underline-position | under puts the line below all descenders, useful for subscripts and math; left and right for vertical text |
text-decoration-skip-ink | auto (default) breaks the line where it would cross descenders; none draws through them; all always skips (Chrome 148) |
text-decoration-inset | shortens (positive) or lengthens (negative) the line at its start and end; one or two lengths, or auto |
text-decoration-inset is new: Firefox 146, Safari 27.3 and Chrome 157. Tested in Chrome 157 with a pixel check: a 90px-wide underline became 70px with text-decoration-inset: 10px, 10px shorter at each end, and 110px with -10px. It's useful to keep adjacent underlined links visually separate, or to stop an underline running under a trailing space or icon.
A modern link style:
a {
color: #8a3b12;
text-decoration-thickness: 0.08em;
text-underline-offset: 0.18em;
text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
a:hover { text-decoration-color: currentColor; text-decoration-thickness: 0.12em; }
Keep links recognizable
Links in body text should be distinguishable without color: an underline is the clearest way. WCAG 1.4.1 (Use of Color) requires that color isn't the only cue. Its technique G183 accepts color-only links if they have 3 contrast with the surrounding text and gain another cue, like an underline, on hover and focus. In navigation menus, where context makes links obvious, underlines are optional.
Decorations propagate and can't be removed
A decoration set on an element is drawn across all its inline content, including descendants, using the element's own color and thickness. And a descendant can't remove it: text-decoration: none on a child only turns off the child's own decoration, not the one drawn by the parent.
p { text-decoration: underline; }
p b { text-decoration: none; } /* the <b> text is still underlined, by the <p> */
Tested in Chrome with a pixel check: the paragraph's underline ran continuously under a <b> with text-decoration: none, and stopped only under an inline-block child.
The workarounds:
- Put the decoration on the elements that need it, not on a container.
- Make the child an inline-block or remove it from the flow: decorations don't propagate into inline-blocks, floats or absolutely positioned descendants.
Links' default underline is on the <a>, so an icon inside a link is underlined too, unless the icon is display: inline-block.
Emphasis marks
Chinese and Japanese typography emphasizes text with small marks next to each character, instead of italic. text-emphasis is a shorthand for the style and color:
em:lang(ja) { font-style: normal; text-emphasis: filled sesame; }
.custom { text-emphasis: "*" #8a3b12; } /* any single character */
| Property | Values |
|---|---|
text-emphasis-style | filled or open with dot, circle, double-circle, triangle, sesame, or a string |
text-emphasis-color | a color |
text-emphasis-position | over or under, optionally with right or left: defaults to over, which puts marks above horizontal text and to the right of vertical text, as Japanese expects (tested in Chrome, the initial value computes to over) |
Emphasis marks work in all browsers, unprefixed since Chrome 99. They take space above the line, so leave enough line-height.
text-shadow
text-shadow draws one or more shadows of the glyphs: offset-x offset-y blur color, comma-separated, with the first on top. Unlike box-shadow, it has no spread and no inset.
h1 { text-shadow: 0 2px 4px rgb(0 0 0 / 0.25); }
/* legible text over a photo */
.hero-title { color: white; text-shadow: 0 1px 2px rgb(0 0 0 / 0.6), 0 0 1em rgb(0 0 0 / 0.4); }
/* a soft glow */
.neon { color: #fff; text-shadow: 0 0 4px #fff, 0 0 12px #ff3d7f, 0 0 24px #ff3d7f; }
Tested in Chrome: 1px 1px 2px rgb(0 0 0 / 0.5), 0 0 1em red is valid, and serializes with the color first. A shadow helps light text stay readable on a busy image, but don't count it toward contrast: check the contrast against the image itself, or put a translucent overlay behind the text (article 35).
body { font: 0.8rem system-ui, sans-serif; margin: 1rem; }
label { display: flex; align-items: center; gap: 0.4rem; }
label input { inline-size: 9rem; }
.links { font-size: 1.4rem; margin: 0.6rem 0; }
.links a {
color: #8a3b12;
text-underline-offset: var(--o, 0.15em);
text-decoration-thickness: var(--t, 0.08em);
text-decoration-inset: var(--i, 0em);
}
.prop { text-decoration: underline 2px #2563eb; font-size: 0.95rem; }
.prop b { text-decoration: none; } /* doesn't remove the paragraph's underline */
.prop .ib { display: inline-block; } /* decorations don't propagate into inline-blocks */
.hero {
margin: 0.6rem 0 0; padding: 0.8rem; border-radius: 8px; font: 700 1.3rem system-ui, sans-serif; color: white;
background: linear-gradient(135deg, #f6d365, #fda085 40%, #5ee7df);
text-shadow: 0 1px 2px rgb(0 0 0 / 0.6), 0 0 0.8em rgb(0 0 0 / 0.35);
}
The inset slider needs Chrome 157, Firefox 146 or Safari 27.3. In the second line, the bold text stays underlined, and only the inline-block escapes the paragraph's underline.

The top-right panel is the propagation rule in action: the <b> sets text-decoration: none, but the paragraph's underline still runs beneath it, and only the inline-block escapes it.
What's current
- Thickness, offset and
skip-ink: all browsers;skip-ink: all: all browsers since Chrome 148. text-decoration-inset: Firefox 146, Safari 27.3 and Chrome 157.spelling-errorandgrammar-errorlines, used with::spelling-errorand::grammar-error(article 13).- Emphasis marks: all browsers.
Common questions
Why can't I remove an underline from part of a link?
Decorations from an ancestor are drawn across descendants and can't be turned off there. Make that part display: inline-block, or underline only the text part.
How do I move the underline away from the text?
text-underline-offset: 0.2em.
Why does my underline have gaps?
text-decoration-skip-ink: auto skips descenders. Set it to none to draw a continuous line.
Does text-shadow fix poor contrast?
Not reliably. Test contrast against the background itself, or add an overlay.
Summary
text-decorationsets line, style, color and thickness, in any order.text-underline-offset,text-underline-position,skip-inkand the newtext-decoration-insetshape the underline.- Decorations propagate to inline descendants and can't be removed there, except by making them inline-blocks or out of flow.
- Body-text links should be underlined or otherwise distinguishable without color.
text-emphasisadds East Asian emphasis marks;text-shadowadds glyph shadows, without spread or inset.
Practice questions
Write a link style with a thin underline 0.2em below the baseline, which thickens on hover.
Answer
a { text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
Why is the <em> still underlined?
<p style="text-decoration: underline">This is <em style="text-decoration: none">important</em>.</p>
Answer
The underline belongs to the paragraph and is drawn across its inline descendants. text-decoration: none on the <em> only removes decorations the <em> would draw itself. Giving the <em> display: inline-block stops the propagation.
What does this do?
.tag { text-decoration: underline 2px; text-decoration-inset: 0.25em; }
Answer
Draws a 2px underline that starts 0.25em after the start of the text and ends 0.25em before its end, in browsers that support text-decoration-inset.
How do you mark emphasis in Japanese text with sesame dots instead of italics?
Answer
em:lang(ja) { font-style: normal; text-emphasis: filled sesame; }
Previous: Text Alignment, Indentation, Spacing and text-transform
Next: White Space, Line Breaking, Hyphenation and text-wrap: balance and pretty

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.