Re: Check existence of class names

On Thu, 12 Aug 2010 19:41:00 +0300, Jukka K. Korpela <> wrote:

> wrote:
>> If a tag has an attribute 'class' with a non-existent name (e.g
>> because of a typo), neither Markup Validator nor CSS Validator
>> catches this.
> Such a situation is not an error of any kind, and there really isn't such a
> thing as "non-existent name". A class is defined by the use of a class
> attribute; the class has no other definition in any formal sense, though in
> practice, it might be described in prose, e.g. in comments.
> It's not a particularly bright-looking attribute, but there is nothing a
> validator could or should complain about it.

All developers whom I know in person, make typing errors. Therefore, I
consider wrong names as errors, and I appreciate any help in finding them.
YMMV, of course.

I do agree that a mistyped class name is not a fatal error. Validator
already has some warnings and notifications about formally correct documents,
e.g. "No Character encoding declared at document level". I ask for another one.

> Even if a markup validator checked the use of a class name in associated
> style sheets (and that's not a validator's job at all - it should parse
> markup, not style sheets or something else) and found out that it's not used

And CSS Validator checks the CSS definitions, not their usage. The problem is
in between Markup and CSS... Definitely this is more about conformance than validity.
Simply Markup Validator has more information ready than CSS Validator.

> at all, there is nothing wrong with the appearance of an unused class name,
> or a name that looks unused. It might be included for preparedness, or for
> use in a client-side script, or for use in a user style sheet.

Yes, you are right, notifying these unused classes would also be useful.

Vladimir Chukharev
Tampere University of Technology

Received on Sunday, 15 August 2010 19:46:34 UTC