A tool that can detect unused/undefined styles would be very useful indeed. Just note that unused styles could be more that just classes. A stylesheet could contain something like this:
Code:
div p.caption { ... }
and if the XHTML does contain <p class="caption">, but not inside a <div>, the above style would be unused. So a CSS checking tool should be a little more sophisticated.
A possible hackish way to look for unused styles: Set everything to display:none, except for one selector. Open the files in a browser. If you see anything, that selector is being used there. Repeat with a different selector, etc.
Finding all undefined styles is harder/impossible. How could an automated tool know that, for this:
Code:
<div class="poetry">
<p>...</p>
<p>...</p>
</div>
the "div.poetry p" style is missing?