The Style object represents an individual style statement.
The Style object can be accessed from the head section of the document, or from specific HTML element(s).
Accessing style object(s) from the head section of the document:
var x = document.getElementsByTagName("STYLE");
Click the button to display the style properties of this document.
<!DOCTYPE html> <html> <head> <style> body {//from www .j a v a 2 s. c om background-color: yellow; color: red; } </style> </head> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementsByTagName("STYLE")[0]; document.getElementById("demo").innerHTML = x.innerHTML; } </script> </body> </html>