/

HTML / CSS / JavaScript Tutorial

CSS Property: text-decoration-line

[this page | pdf | back links]

The CSS (CSS3) text-decoration-line property indicates the type of line 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. Multiple values can be combined (e.g. underline and overline)

 

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

 

Value

Description

line-through

Last line is aligned left

none

(default value). Normal text, without decoration

overline

Add line above text

underline

Add line below text

 

Default Value:

none

JavaScript syntax:

e.g. object.style.textDecorationLine="line-through"

Inherited:

No

Animatable:

No

 

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-line: underline}
</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.textDecorationLine = "underline";
</script>

</body>
</html>

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


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile