I am not sure where to pitch this question. Here or w3 consortium or ...
One of the main concepts of using css when introduced was to get rid of the extra code in an html page. It allowed the cleaning up of html so the inline styles and other cruft was reduced and html become human readable again, as well as more easily parsed by readers etc.
Over time this concept seems to be getting lost.
Example:
<div id="MainArticle" style="border:0px; margin:10px; width:80%; color:red; align:center;">
became
<div id="MainArticle">
with a link to the css file dragging the rest of the design in.
However most modern websites you see code more like:
<div id="MainArticle" class="col-md-9 col-sm-12 col-lg-8 MainArticleClass FloatingStyles OtherClass">
Which IMHO is heading back into the cluttered mess css was meant to remove.
One way around this would be to be able to declare a div in css and then import the class into the div leaving only one identifier required in the html e.g
<div id="MainArticle">
style.css
#MainArticle {
@import col-md-9, col-sm-12, col-lg-8, MainArticleClass, FloatingStyles, OtherClass;
}
I would assume something like this would require the same bandwidth to download, as the css file would remain 99.5% the same, except a change in the #MainArticle declaration but there would be a reduction in the html size as you remove the class declarations there - for a sum total of no extra data used.
There would be some over head looking up the imports in the css, on the fly, but most computers are so fast we aren't talking a lot of pain there. By allowing only div identifiers to import only class identifiers you get rid of circular dependencies.
Maybe there would be an issue of specificity invoked but that's not over likely.
Is there any discussions around on something like this? any pointers to articles etc would be appreciated.
I know you can overload the css declarations e.g you could add #MainArticle to the declarations for all the css classes referenced but that is a nightmare to maintain and breaks external stylesheets pulled in.
e.g.
.col-md-9, #MainArticle{
width:75%;
}
.col-lg-8, #MainArticle{
width:66.66%;
}