How to change FontSize By JavaScript?

jams picture jams · Apr 7, 2011 · Viewed 126.3k times · Source

This code is not working

var span = document.getElementById("span");
span.style.fontsize = "25px";
span.innerHTML = "String";


Answer

ambiguousmouse picture ambiguousmouse · Apr 7, 2011

JavaScript is case sensitive.

So, if you want to change the font size, you have to go:

span.style.fontSize = "25px";