How to set the style of the line in a text decoration with JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To set the style of the line in JavaScript, use the textDecorationStyle property. You can set underline, double, or overline, etc for the line style.


You can try to run the following code to return the style of the line in a text-decoration with JavaScript −

<!DOCTYPE html>
      <div id = "myText" style = "text-decoration: underline;">
         This is demo text.
      <button onclick = "display()"> Set Text Decoration </button>
         function display() {
            document.getElementById("myText").style.textDecorationColor = "red";
            document.getElementById("myText").style.textDecorationStyle = "double";
Updated on 23-Jun-2020 11:24:41