tags:

views:

1405

answers:

4

I'm looking for a tool that can scan over a set of HTML pages, and check for bad or out of sync CSS usage. In particular, I want to check the following:

  1. Each CSS rule in the CSS files is used at least once by some HTML page.
  2. Each CSS class referenced on the HTML pages is actually defined in a CSS file.
  3. (Nice to have) that inline styles do not duplicate existing CSS classes (e.g. that there are no tags with inline styles for which there is an equivalent CSS class already defined).

Is there an existing tool that will do this?

+1  A: 

W3 has a CSS checker.

Charlie Martin
That's just a validator, though - it checks for things like misspelled or nonexistent properties, but I don't think it does what the OP is asking.
David Zaslavsky
No, it doesn't do any of what I'm looking for, unfortunaly. It also reports a lot of spurious errors, especially around IE hacks.
A: 

I'm not sure if it's an option, but Visual Studio will take care of #2 for you. It actually is kind of annoying when you're using classes that aren't styled, but used for Javascript.

Stuart Branham
A: 

I'm not sure if it has all of the requirements you have but I would definitely check out CSS Tidy. It is marketed as a CSS parser and optimizer.

Otherwise, I'm not sure if there's anything out there besides good ol' "using good practices" while developing the project.

T Pops
+4  A: 

You might want to take a look at Dust-Me Selectors see also: http://www.sitepoint.com/dustmeselectors/

I think it handles #1 and #2, but not sure about #3

Andy Ford
Great tool + 1.
The Pixel Developer
thanks! that was exactly what I wanted.