What are we facing?
Anyone working in large web projects in collaboration with many people at the same time will see the consecuences of many hands on style files. May selectors and classes come and go while developing and testing. After a while, you will easily see style files that become untouchable: you don't know which classes or selectors are being used or not. The same uncertainty creeps in when you maintain someone else's site.
The Solution
There are several solutions out there about detecting unused classes and selectors, I will list the most popular:
- Dust-Me Selectors: "Dust-Me Selectors is a Firefox extension (for v1.5 or later) that finds unused CSS selectors. It extracts all the selectors from all the stylesheets on the page you're viewing, then analyzes that page to see which of those selectors are not used. The data is then stored so that when testing subsequent pages, selectors can be crossed off the list as they're encountered"
- TopStyle 3.5 for Windows: It has a "orphan classes report".
- CSS Redundancy Checker: It's a free online service. "Use this tool to find CSS selectors that aren't used by any of your HTML files and may be redundant".
- Unused CSS Cleaner: "This tool helps you find orphaned CSS styles (Classes, IDs) that are present in the stylesheets but not used in the web pages".
- IntelliJ IDEA - HTML/XHTML/CSS Editor: "CSS on-the-fly validation: Unused CSS class definitions".
- Style Studio CSS Editor: It has a "Selector Report that detect Unused CSS CLASSes/IDs".
- Expression Web's CSS Reports: The CSS reporting feature is a way to examine unused CSS styles that need to be cleaned up".
Some external references