Skip to content

Latest commit

 

History

History
97 lines (67 loc) · 3.34 KB

File metadata and controls

97 lines (67 loc) · 3.34 KB
title slug page-type browser-compat
text-decoration-color
Web/CSS/text-decoration-color
css-property
css.properties.text-decoration-color

{{CSSRef}}

The text-decoration-color CSS property sets the color of decorations added to text by {{ cssxref("text-decoration-line") }}.

The color applies to decorations, such as underlines, overlines, strikethroughs, and wavy lines like those used to mark misspellings, in the scope of the property's value.

{{EmbedInteractiveExample("pages/css/text-decoration-color.html")}}

CSS does not provide a direct mechanism for specifying a unique color for each line type. This effect can nevertheless be achieved by nesting elements, applying a different line type to each element (with the {{cssxref("text-decoration-line")}} property), and specifying the line color (with text-decoration-color) on a per-element basis.

Syntax

/* <color> values */
text-decoration-color: currentcolor;
text-decoration-color: red;
text-decoration-color: #00ff00;
text-decoration-color: rgb(255 128 128 / 50%);
text-decoration-color: transparent;

/* Global values */
text-decoration-color: inherit;
text-decoration-color: initial;
text-decoration-color: revert;
text-decoration-color: revert-layer;
text-decoration-color: unset;

Values

  • {{cssxref("<color>")}}
    • : The color of the line decoration.

Accessibility concerns

It is important to ensure that the contrast ratio between the color of the text, the background the text is placed over, and the text decoration line is high enough that people experiencing low vision conditions will be able to read the content of the page. Color contrast ratio is determined by comparing the luminosity of the text and background color values.

Color alone should not be used to convey meaning. For example, change of text and text-decoration-color alone is not enough to indicate a link has focus.

Formal definition

{{CSSInfo}}

Formal syntax

{{csssyntax}}

Examples

Basic example

<p>
  This paragraph has <s>some erroneous text</s> inside it that I want to call
  attention to.
</p>
p {
  text-decoration-line: underline;
  text-decoration-color: cyan;
}

s {
  text-decoration-line: line-through;
  text-decoration-color: red;
  text-decoration-style: wavy;
}

{{ EmbedLiveSample('Examples') }}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • When setting multiple line-decoration properties at once, it may be more convenient to use the {{cssxref("text-decoration")}} shorthand property instead.
  • The {{cssxref("<color>")}} data type
  • Other color-related properties: {{cssxref("background-color")}}, {{cssxref("border-color")}}, {{cssxref("outline-color")}}, {{cssxref("text-decoration-color")}}, {{cssxref("text-emphasis-color")}}, {{cssxref("text-shadow")}}, {{cssxref("caret-color")}}, and {{cssxref("column-rule-color")}}