JavaScript – Change the Font Size of HTML Element

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

In the following example, we will change the font size of HTML Element with id "myElement" to "25px", in JavaScript, using element.style.fontSize property.

example.html

ADVERTISEMENT

Conclusion

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