style object to support all your CSS needs.
<html> <body> <p id="p1">Hello World!</p> <script> document.getElementById("p1").style.color = "red"; </script> <p>The paragraph above was changed by a script.</p> </body> </html>
// Get a reference to the element var myElement = document.querySelector("#p1"); // Now you can update the CSS attributes myElement.style.color = "red"; myElement.style.backgroundColor = "yellow";
Note that where CSS properties would use
dashes to separate words, like
background-color would become