Aabestfontgenerator.
THE TYPE NOTEBOOK

CSS Underlines, Thickness and Offset

Style a CSS underline, adjust its thickness and offset and check it around descenders, wrapped links and focus states.

Use text-decoration to draw an underline. Set its offset separately when the line needs more clearance below the text.

Sources reviewed .

01

Start with the underline on the actual element

For a link class, start with text-decoration: underline. The CSS Text Decoration specification describes separate properties for the line, style, color and thickness. Add one visual change at a time. Keep the underlying link or other semantic element intact when changing the decoration.

02

Use offset for clearance around descenders

Try text-underline-offset: 0.15em and inspect a phrase with g, p and y. Compare that with the browser’s default. Use text-decoration-thickness when the line itself needs a different weight. Proof a two-line link so the decoration is readable even where adjacent lines are close together.

03

Check links in their actual page context

Inspect a visited link, keyboard focus and a link that wraps at a narrow width. Keep the indication recognizable when the underline color changes. The underline font page covers a separate plain-text style approach. Use the homepage styling tool for a caption that does not need CSS markup.

GOOD QUESTIONS

Your questions, answered.

How do I move the underline farther from the word?

Use text-underline-offset and compare a short proof with descenders.

Can I make it thicker without moving it?

Set text-decoration-thickness independently from text-underline-offset.

Sources & background

Sources supporting this page’s explanations. Practical examples are our editorial suggestions.