HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <link rel="stylesheet" title="blue" type="text/css" href="/blue.css"> <link rel="stylesheet" title="brown" type="text/css" href="/brown.css"> </head> <body> <p>Click on the button to display the css file "blue.css"</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <p><strong>Note</strong>: Swap the two css link (inside &lt;head&gt; tag) and click 'Run' button and try again.</p> <script> var x = document.getElementById("point"); var css1 = document.styleSheets[0]; var len = css1.cssRules.length; var txt = ""; function myFunction(){ for(var i=0; i<len; i++){ txt += css1.cssRules[i].cssText + "<br>"; } x.innerHTML = txt; } </script> <p><strong>Note</strong>: The CSS files used in the following examples are <a href="/blue.css" target="_blank">blue.css</a> and <a href="/brown.css" target="_blank">brown.css</a></p> </body> </html>
OUTPUT
×

Save as Private