Place an underline around letters with descenders
Admin ·
A descender such as the tail of a g can meet a decorative line. Adjust its position and whether the browser skips the ink before reusing the style.
Start with the wavy three-pixel underline
Select Reset example. Rising type uses a wavy underline, three pixels of thickness and six pixels of underline offset. Change the sample to early glyphs to add several descenders.
Switch Skip ink to Draw through glyph ink and compare the line with the automatic setting. The automatic behavior depends on where your browser paints the line around the glyphs.
| Setting | Example value | CSS property |
|---|---|---|
| Line style | wavy | text-decoration-style |
| Line thickness | 3 px | text-decoration-thickness |
| Underline offset | 6 px | text-underline-offset |
| Draw through glyph ink | none | text-decoration-skip-ink |
W3C CSS Text Decoration Level 4, line decorationsW3C CSS Text Decoration Level 4, underline offset and ink skipping
Compare two decoration lines on the same text
Select Strike-through as well as Underline. The output contains underline line-through in one text-decoration-line declaration. The style, color and thickness apply to both lines.
Change Underline offset to 10 pixels and compare before and after. The underline moves relative to its default position. The strike-through stays governed by the browser’s line placement.
W3C CSS Text Decoration Level 4, line decorationsW3C CSS Text Decoration Level 4, underline offset and ink skipping
Apply the exported class to the target element
Download text-decoration.css and include it in your project. Apply tm-decorated-text to the element you want to decorate. The preview phrase is working text, so use your own content.
If a different font changes how the decoration sits on the letters, try From font in Thickness source to use the font’s available metrics. Recheck both wrapped and single-line text.
text-decoration-line: underline line-through;
text-decoration-thickness: 3px;
text-underline-offset: 10px;W3C CSS Text Decoration Level 4, underline offset and ink skipping
Common questions
Can I set separate colors for the underline and strike-through?
One generated rule shares its decoration color. Separate elements or additional CSS rules can originate separate decorations.
What happens if the font has no decoration thickness metrics?
For from-font, the browser falls back to its automatic thickness choice.