Set the text decoration for a <p> element:
document.getElementById("myP").style.textDecoration = "underline overline";
<!DOCTYPE html> <html> <body> <p id="myP">This is an example paragraph.</p> <button type="button" onclick="myFunction()">Decorate text</button> <script> function myFunction() {// www.j a v a 2s . c o m document.getElementById("myP").style.textDecoration = "underline overline"; } </script> </body> </html>
The textDecoration property sets or gets one ore more decorations for a text.
To specify more than one decoration type, use a space separated list of decoration types.
Property Values
Value | Description |
---|---|
none | a normal text. 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. |
The textDecoration property returns a String representing the decoration added to the text.