1<html>
2<body>
3
4<p id="p2">Hello World!</p>
5
6<script>
7document.getElementById("p2").style.color = "blue";
8</script>
9
10<p>The paragraph above was changed by a script.</p>
11
12</body>
13</html>
1var elem = document.querySelector('#some-element');
2
3// Set color to purple
4elem.style.color = 'purple';
5
6// Set the background color to a light gray
7elem.style.backgroundColor = '#e5e5e5';
8
9// Set the height to 150px
10elem.style.height = '150px';
11
1// Getting the element first
2var myElement = document.querySelector("#myElement");
3
4// examples for updating styles
5myElement.style.color = "blue";
6myElement.style.backgroundColor = "red";