/

HTML / CSS / JavaScript Tutorial

CSS Property: text-decoration-color

[this page | pdf | back links]

The CSS (CSS3) text-decoration-color property indicates the colour of the text decoration added to a given piece of text. For this property to have an effect, a visible text-decoration needs to have been applied to the text.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

color

A CSS colour

 

Default Value:

Colour of text

JavaScript syntax:

e.g. object.style.textDecorationColor="red"

Inherited:

No

Animatable:

Yes

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 200px; text-decoration: overline;}
.x1 {text-decoration-color: red}
</style>
</head>
<body>
Note: not all browsers support this style<br><br>
1. Element with default property<br><br>
<div><span>abcde</span></div><br><br>
2. Element set using in-file HTML style<br><br>
<div><span class="x1">abcde</span></div><br><br>
3. Element set using JavaScript<br><br>
<div><span id="x2">abcde</span></div>

<script>
document.getElementById("x2").style.textDecorationColor = "red";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyTextDecorationColor() {
  var x = document.createElement("DIV"); x.style.textDecorationColor = "red"; return (window.getComputedStyle(x, null).textDecorationColor == "red");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile