textDecoration Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:textDecoration

Description

The textDecoration property sets or gets one ore more decorations for a text.

To set more than one decoration type, use a space separated list of decoration types.

Property Values

ValueDescription
none a normal text. This is default
underlinea line under the text
overline a line over the text
line-through a line through the text
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: none
Return Value: A String, representing the decoration added to the text
CSS VersionCSS1

Set the text decoration for a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
p#myP {/*www. j av  a2s.  c  o  m*/
    text-decoration: underline;
}
</style>
</head>
<body>

<p id="myP">
Hello world!
</p>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("myP").style.MozTextDecorationStyle = "overline"; // Code for Firefox
    document.getElementById("myP").style.textDecorationStyle = "overline";
}
</script>

</body>
</html>

Related Tutorials