Creating and Modifying Elements
Changing CSS
JavaScript can modify CSS using .style.
<h1 id="title">Hello</h1>
const title = document.querySelector("#title");
title.style.color = "red";
title.style.fontSize = "40px";
title.style.backgroundColor = "black";
CSS property names change slightly in JavaScript.
CSS:
background-color
JavaScript:
element.style.backgroundColor = "red";