This chapter covers the following properties:
The text-decoration-line property is employed to apply a decorative line to text.
Tip: You can combine multiple values, such as overline and underline, to simultaneously display lines both above and below text
Example
h1 { |
Note: It is advised against underlining text that isn’t a hyperlink, as it can often cause confusion for readers. |
The text-decoration-color property determines the color of the decorative line.
Example
h1 { |
The text-decoration-style property defines the style of the decorative line.
Example
h1 { text-decoration-line: underline; text-decoration-style: solid; } h2 { text-decoration-line: underline; text-decoration-style: double; } h3 { text-decoration-line: underline; text-decoration-style: dotted; } p.ex1 { text-decoration-line: underline; text-decoration-style: dashed; } p.ex2 { text-decoration-line: underline; text-decoration-style: wavy; } p.ex3 { text-decoration-line: underline; text-decoration-color: red; text-decoration-style: wavy; } |
h1 { text-decoration-line: underline; text-decoration-thickness: auto; } h2 { text-decoration-line: underline; text-decoration-thickness: 5px; } h3 { text-decoration-line: underline; text-decoration-thickness: 25%; } p { text-decoration-line: underline; text-decoration-color: red; text-decoration-style: double; text-decoration-thickness: 5px; } |
The text-decoration property serves as a shorthand for specifying:
Example
h1 { text-decoration: underline; } h2 { text-decoration: underline red; } h3 { text-decoration: underline red double; } p { text-decoration: underline red double 5px; } |
By default, all links in HTML are underlined. However, it’s common to style links without underlines. This is achieved by utilizing text-decoration: none; to remove the underline from links, like so:
Example
a { |
Property |
Description |
text-decoration |
Combines all text-decoration properties into a single declaration. |
text-decoration-color |
Defines the color of the text decoration. |
text-decoration-line |
Determines the type of text decoration to apply (underline, overline, etc.). |
text-decoration-style |
Defines the style of the text decoration (solid, dotted, etc.). |
text-decoration-thickness |
Indicates the thickness of the text decoration line. |