JavaScript – Change Font Color of HTML Element

To change the font color of a HTML Element using JavaScript, get reference to this HTML element, and assign required color value to the element.style.color property.

In the following example, we will change the font color of HTML Element with id "myElement" to the color "#FF0000", in JavaScript, using element.style.color property.

example.html

ADVERTISEMENT

Conclusion

In this JavaScript Tutorial, we learned how to change the font color of a HTML Element using JavaScript.