This is a difficult task ... especially if your HTML DOM content is generated on the fly in any way.
The Dust-Me-Selectors plugin is useful, but page by page, many selectors will not be used ... but will not necessarily be invalid.
Here are a few tricks I used to help cleanse.
One by one, insert some HORRID style that you can detect right away to determine if the selector is being used. eg.
border:6px dashed #ffaacc; padding:12px;
Everything that does with a huge dotted pink border is now ... an "active" selector. If you can view most of your site / application without seeing it, then it is most likely "dead."
(if your CSS code is "generated", you can optimize it for testing with different colors at the same time; and use the generated content to add the "id" selector)
Another option, if you are using the generated CSS system ... is to add the final property to your selector, which sets ... the background image with the generated URL. eg.
#selector_a > .foo{ ... background-image:url('selectortest/id_123.png'); }
Then you just browse your site / application for a while, and then check your weblog for HTTP image requests ... for any generated image URL that was not requested in the log ... you probably found "dead" .
source share