<html>
<style>
.democlass {color:red}
</style>
<body>
<h1>HTML DOM Attributes</h1>
<h2>The setNamedItem() Method </h2>
<p>Set the first H1's class attribute to "democlass".</p>
<script>
const nodeMap = document.getElementsByTagName("H1")[0].attributes;
const node = document.createAttribute("class");
node.value = "democlass";
nodeMap.setNamedItem(node);
</script>
</body>
</html>