The Header object represents an HTML <header> element.
We can access a <header> element via document.getElementById()
:
var x = document.getElementById("myHeader");
Click the button to set the color of the header element to red.
<!DOCTYPE html> <html> <body> <article> <header id="myHeader"><h3>CSS</h3></header> <p>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. ....</p>//from w w w . jav a 2s . c om </article> <button onclick="myFunction()">Test</button> <script> function myFunction() { var x = document.getElementById("myHeader"); x.style.color = "red"; } </script> </body> </html>