Friday, 18 September 2015

JavaScript to fetch CSS from WebPage

CSS Solved a Big Problem
HTML was NEVER intended to contain tags for formatting a document.
HTML was intended to define the content of a document, like:

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large web sites, where fonts and color information were added to every single page, became a long and expensive process.

In HTML 4.0, all formatting could (and should!) be removed from the HTML document, and stored in a separate CSS file.

Ex –

<!DOCTYPE html>
p {
    text-align: center;
    color: red;

<p>Every paragraph will be affected by the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>


java script to fetch css  

var elems = document.getElementsByTagName('*');
var source = [];
var css = returnCSS(elems);
function returnCSS(elems){
for(var i=0; i<elems.length ; i++){
return source;

No comments:

Post a Comment