CSS Property: text-decoration
[this page | pdf | back links]
The CSS (CSS1) text-decoration property indicates the
‘decoration’ (e.g. underlining) added to text. Note in CSS3 the text-decoration
property is supposed to be a shorthand property covering text-decoration-line,
text-decoration-color
and text-decoration-style
but at the time of writing this interpretation was not supported by major
browsers.
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.textDecoration="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; background-color: yellow}
.x1 {text-decoration: overline;}
</style>
</head>
<body>
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.textDecoration = "overline";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyTextDecoration() {
var x = document.createElement("DIV"); x.style.textDecoration = "overline"; return (window.getComputedStyle(x, null).textDecoration == "overline");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties