text-decoration – CSS: Cascading Style Sheets

The text-decoration shorthand CSS property sets the appearance of decorative lines on text. It is a shorthand for text-decoration-line, text-decoration-color, text-decoration-style, and the newer text-decoration-thickness property.

Text decorations are drawn across descendant text elements. This means that if an element specifies a text decoration, then a child element can’t remove the decoration. For example, in the markup

This text has some emphasized words in it.

, the style rule p { text-decoration: underline; } would cause the entire paragraph to be underlined. The style rule em { text-decoration: none; } would not cause any change; the entire paragraph would still be underlined. However, the rule em { text-decoration: overline; } would cause a second decoration to appear on “some emphasized words”.

This property is a shorthand for the following CSS properties:

text-decoration: underline; text-decoration: overline red; text-decoration: none; text-decoration: inherit; text-decoration: initial; text-decoration: revert; text-decoration: unset;

The text-decoration property is specified as one or more space-separated values representing the various longhand text-decoration properties.

Values

Demonstration of text-decoration values

.under { text-decoration: underline red; } .over { text-decoration: wavy overline lime; } .line { text-decoration: line-through; } .plain { text-decoration: none; } .underover { text-decoration: dashed underline overline; } .thick { text-decoration: solid underline purple 4px; } .blink { text-decoration: blink; }

This text has a line underneath it.

This text has a line over it.

This text has a line going through it.

This link will not be underlined, as links generally are by default. Be careful when removing the text decoration on anchors since users often depend on the underline to denote hyperlinks.

This text has lines above and below it.

This text has a really thick purple underline in supporting browsers.

BCD tables only load in the browser

Source

Leave a comment

Your email address will not be published. Required fields are marked *