text-decoration-line

Term side of the Card.
Topic: Text Handling
Unit title: text-decoration-line
Categories: Property
Explanation side of the Card

Explanation: The property that defines what type of line decoration will be applied to text, such as 'underline', 'overline' or 'line-through'. It allows for combining multiple lines, such as underlining and striking through, to create different text decoration effects.

Browser compatibility:
  • The chrome browser supports this feature starting from version 57.
  • The edge browser supports this feature starting from version 79.
  • The firefox browser supports this feature starting from version 36.
  • The safari browser supports this feature starting from version 12.1.
Availability: 

Example

Wrongcss
.price-old {
  text-decoration-line: underline, line-through;
}
Rightcss
.price-old {
  text-decoration-line: underline line-through;
}

Several line values are separated by spaces; with a comma the declaration is invalid and gets ignored.

Common mistakes

  • A sale price is crossed out with CSS only, so screen readers don't know it is the old price.
  • Setting text-decoration-line twice keeps only the last value instead of both lines.

Key points

  • Removed or outdated content uses <del> or <s>, not only text-decoration-line: line-through.
  • Several lines are space-separated in one value, like underline overline.

Interview questions

Can I combine underline and line-through?

Yes. List both in one value: text-decoration-line: underline line-through.

What is the difference between del and s?

<del> marks content removed from a document. <s> marks content that is no longer accurate or relevant.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy