JavaScript – Underline Text in HTML Element
To underline text in HTML Element using JavaScript, get reference to the HTML Element element, and assign element.style.textDecoration
property with value of "underline"
.
In the following example, we will underline the text in HTML Element with id "myElement"
in JavaScript, using element.style.textDecoration
property.
example.html
ADVERTISEMENT
Conclusion
In this JavaScript Tutorial, we learned how to underline text in a HTML Element using JavaScript.