Skip to main content

CSS Text Decoration

The text-decoration property controls the decorative lines on text.

It is a shorthand for these properties: text-decoration-line, text-decoration-color, text-decoration-style, and text-decoration-thickness.


Add a Decoration Line to Text

The text-decoration-line property sets the type of line added to the text. It can take one or more of these values:

  • none — the default, no line.
  • underline — a line under the text.
  • overline — a line over the text.
  • line-through — a line through the text.

Tip: You can combine values, like overline underline, to show lines both over and under the text.

Note: It is best not to underline text that is not a link, as it can confuse the reader.

Example

Each element shows a different decoration line, and the paragraph combines two.

Prompt
An HTML page that shows the text-decoration-line property. In an internal <style> block, give the <h1> an overline, the <h2> a line-through, the <h3> an underline, and the <p> both overline and underline. Add a heading of each level and a paragraph.
Output: complete HTML page

Specify a Color for the Decoration Line

The text-decoration-color property sets the color of the decoration line.

Example

The decoration lines are given different colors with text-decoration-color.

Prompt
An HTML page that shows the text-decoration-color property. In an internal <style> block, give the <h1> a red overline, the <h2> a blue line-through, the <h3> a green underline, and the <p> a purple overline and underline, using text-decoration-line and text-decoration-color together. Add a heading of each level and a paragraph.
Output: complete HTML page