When to use
Do this any time you want to change CSS style on a web page.
Given this p tag:
<p id="first">Hello World!</p>
To change the CSS style to make the text blue, we would do this:
document.getElementById("first").style.color = "blue";
.style.property can change any CSS!
Hints & tips
- .style.property can change any CSS
- Remember to use lowercase Camel Case when renaming CSS properties that normally have dashes
Lesson notes are only available for subscribers.