b2KIT

CSS Text Underline Decorator

Design custom text underlines using text-decoration, border-bottom, and background-image techniques.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Text Underline Decorator does and how it behaves

Shape an underline by choosing among three distinct CSS approaches: native text decoration, a bottom border, or a positioned background image. Each approach controls a different part of the result. Text decoration follows the text, border-bottom follows the element box, and background-image can form a custom stripe or pattern. The common surprise is that these methods are not interchangeable: the same thickness and offset values can produce visibly different lines, especially when text wraps or uses another font.

How the result is produced

1

Native text decoration

The text-decoration approach describes the line with decoration-specific properties such as line type, color, style, and thickness. text-underline-offset can move an underline away from the text without adding padding. This approach remains tied to glyph rendering, so its exact position can vary with the selected font and the browser's handling of underline metrics.

2

Box and background techniques

A border-bottom underline is drawn at the bottom edge of the styled element's box, making padding part of the distance between text and line. A background-image underline is painted as a background, where background size, position, and repetition can create a stripe, gradient, or repeating pattern. These alternatives are decorative box effects rather than native text decorations.

Good uses

  • Creating a link underline with a controlled color, thickness, and gap below the letterforms.
  • Comparing text-decoration with border-bottom before styling navigation labels that may wrap.
  • Building a gradient, dashed-looking, or patterned underline that native decoration styles cannot reproduce precisely.

Limits and checks

  • Do not treat equal numeric settings across the three techniques as visually equivalent. They use different positioning models.
  • Test wrapped text explicitly. A border or background may fragment, repeat, or span line boxes differently from a native underline.
  • Check forced-colors and high-contrast modes. Background-image decoration may be suppressed, while native text decoration can remain more recognizable.

Common questions

Which technique should I use for an ordinary link underline?

Start with text-decoration when the line should behave like an underline attached to the text. It supports underline-specific thickness, offset, color, and style controls. Border-bottom is useful when the line must follow the element box. Background-image is appropriate for custom graphical effects, but no, it should not be assumed to behave like a native underline.

Will the underline look identical with every font and browser?

No. Native underline placement can reflect font metrics, while border and background positions depend on the element box and its sizing. Font substitution, line height, wrapping, zoom, and browser rendering can therefore change the apparent gap or thickness. Verify the generated style using the actual font, text sizes, states, and line lengths used by the page.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools