Javascript examples for CSS Style Property:textDecoration
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.
Value | Description |
---|---|
none | a normal text. This is default |
underline | a 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. |
Item | Value |
---|---|
Default Value: | none |
Return Value: | A String, representing the decoration added to the text |
CSS Version | CSS1 |
Set the text decoration for a <p> element:
<!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>