Is there a way to script audit CSS? I just need file level information, not individual rules. It seems like the page really needs to be displayed in order to get accurate information ... so maybe something like Selenium can help?
I have seen that there are browser plugins for checking CSS files (for example, this https://stackoverflow.com/a/16795/147/) , this Article from the Apart list ), but manually viewing the results for each page will take too much time.
Background
Over the years, various CSS files have been embedded in our web application template header. This is a huge pain trying to style an element when there are overlapping rules from several frameworks, plugins, etc. Everyone is fighting for excellence.
As part of an attempt to consolidate / standardize, I would like to move the old links from the site template and to separate page headers, so the effect of CSS rules will be limited only where they are used / necessary.
I think the easiest way would be to go around the site and keep track of which CSS styles are used there.
UPDATE
Inadvertent rule matches are possible, so I'm starting to think that I can't script this. We probably have to go through the pages. Even then, the styling of some pages may rely on a strange intersection of opposing stylesheets: - /
In addition, I am skeptical of these static CSS checkers, especially with template files. The rule ul > li.special may not correspond to anything before execution (elements can be created on the server side or javascript)
html css selenium web-scraping
David j
source share