text-decoration-style

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

Explanation: The property that defines the style of the text decoration, such as 'solid', 'wavy', 'dotted', 'dashed' or 'double'. This property allows for customization of the appearance of underlines, overlines and line-throughs, giving more creative options for text styling.

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
.error {
  text-decoration-style: wavy;
  text-decoration-color: red;
}
Rightcss
.error {
  text-decoration: underline wavy red;
}

The shorthand sets the line, style and color together, so the wavy underline actually appears.

Common mistakes

  • The wavy style doesn't show because no decoration line is set.

Key points

  • A decoration line is set too, since text-decoration-style alone draws nothing.
  • Wavy underlines are not used on normal links, where users expect a solid line.

Interview questions

What values does text-decoration-style accept?

solid, double, dotted, dashed and wavy.

How do I make a dashed underline?

Use text-decoration: underline dashed, or set text-decoration-style: dashed along with an underline line.

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