Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any tools to identify undefined CSS/HTML classes?

Tags:

html

css

Are there any tools out there that can look at my website HTML and tell me that (for example) "there is an HTML element at mysite.com/example.html using a class of SOMECLASS but SOMECLASS is not defined in any included CSS files".

?

like image 927
Dougal Avatar asked May 21 '10 15:05

Dougal


People also ask

How do I know which CSS class is not used?

Install the CSS Usage add-on for Firebug and run it on that page. It will tell you which styles are being used and not used by that page.

How do I identify a class in CSS?

The .class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.

Can CSS classes start with numbers?

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit.


1 Answers

I've created a snippet that does exactly that: https://gist.github.com/kdzwinel/426a0f76f113643fa285

You can run it in the DevTools console and the sample output will look like this:

Sample output from the CSS un

like image 95
Konrad Dzwinel Avatar answered Oct 06 '22 02:10

Konrad Dzwinel