Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Document Object</h1>
<h2>The querySelectorAll() Method</h2>
<p>Set the background color of all h3 and span elements:</p>
<h1>A H1 element</h1>
<h2>A H2 element</h2>
<h3>A H3 element</h3>
<p>A p element.</p>
<p>A p element with a <span style="color:brown;">span</span> element.</p>
<script>
const list = document.querySelectorAll("h3, span");
for (let i = 0; i < list.length; i++) {
  list[i].style.backgroundColor = "red";
}
</script>
</body>
</html>