<!DOCTYPE html>
<html>
<body>

<h3>A demonstration of how to access a CODE element</h3>

<code id="myCode">A piece of computer code</code>

<p>Click the button to set the color of the code element to red.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var x = document.getElementById("myCode");
    x.style.color = "red";
}
</script>

</body>
</html>