CSS Text & Fonts

CSS Text Decoration

The CSS Text Decoration property is used to add or remove decorative lines from text.

It is commonly used to:

  • Underline text
  • Add overlines
  • Strike through text
  • Remove underlines from links

Text decoration helps emphasize content and improve the visual appearance of web pages.

Syntax

CSS Text Decoration Syntax

css

selector {
    text-decoration: value;
}

CSS Text Decoration Example

css

h1 {
    text-decoration: underline;
}

This adds an underline below all <h1> elements.

Attributes

ValueDescriptionExample
noneRemoves decorationtext-decoration: none;
underlineAdds a line below the texttext-decoration: underline;
overlineAdds a line above the texttext-decoration: overline;
line-throughAdds a line through the texttext-decoration: line-through;
underline overlineApplies multiple decorationstext-decoration: underline overline;

Example

CSS Text Decoration Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS Text Decoration Example</title>
    <style>
        .underline {
            text-decoration: underline;
        }
        .overline {
            text-decoration: overline;
        }
        .line-through {
            text-decoration: line-through;
        }
        .no-decoration {
            text-decoration: none;
        }
    </style>
</head>
<body>
    <h1 class="underline">Underlined Heading</h1>
    <p class="overline">This paragraph has an overline.</p>
    <p class="line-through">This text has a line through it.</p>
    <a href="#" class="no-decoration">Link Without Underline</a>
</body>
</html>

Output

Browser Output

css

The heading will appear with an underline
The first paragraph will have an overline
The second paragraph will have a line through the text
The link will appear without the default underline

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE
YesYesYesYesYesYes

Notes

  • Links (<a>) are underlined by default in most browsers.
  • text-decoration: none; is commonly used to remove link underlines.
  • Multiple decorations can be combined.
  • Modern CSS also supports text-decoration-color, text-decoration-style, and text-decoration-thickness.
  • Text decoration affects only the appearance of text, not its functionality.

Conclusion

The CSS Text Decoration property allows you to add visual emphasis to text through underlines, overlines, and strike-through effects. It is especially useful for styling links and highlighting important content while maintaining a clean and professional design.