Re: Check existence of class names

On Tue, 17 Aug 2010 23:56:46 +0300, Philip Taylor (Webmaster, Ret'd) <P.Taylor@rhul.ac.uk> wrote:

> chukharev@mail.ru wrote:
>
>> Why do you dislike this kind of terminology?
>
> Just that it is not the way HTML is constructed/defined/whatever.

I thought we have agreed that the problem lyes neither in HTML nor
in CSS, rather in their interaction?

> A class exists from the moment that you first use it, whether
> you use it in error :
>
> 	<p class="Fist">
>
> or as you intended :
>
> 	<p class="First">
>
> There is no difference : both cause the class to exist
> where it did not previously do so.

Right.

>> No. I really want to distinguish the defined/constructed classes
>> (plus preexisting classes like p)
>
> An interrupt at this point : "p" is not a pre-defined
> class; it is the name of an element, and the syntax
> for its use, both in HTML & in CSS, is different from
> the syntax required for class names.

OK. Just this has to be taken into account, at least in case
of finding unused names...

>> from the names used accidentally
>> due to typing errors. The definition might be in a different linked
>> file.
>>
>> Consider something like the following with the definition in
>> the same file.
>> ...
>> <style type="text/css">
>> physicists chemists {...}
>> </style>
>
> Returning to interrupt : that should read --
>
>  > <style type="text/css">
>  > .physicists, .chemists {...}
>  > </style>

Right, mea culpa. (I'm not good in CSS at all. That's one of
the reasons for the plead. Mostly, I modify existing styles,
and I make many errors when defining new classes.)

>> ...
>> <span class="physicist">Albert Einstein</span> ...
>> <span class="chemist">Dmitry Mendeleev</span> ...
>> <span class="physisists">Christiaan Huygens</span> ...
>> <span class="physicists">J.J. Thomson</span> ...
>> <span class="physisists">Niels Bohr</span> ...
>> ...
>>
>> class="physisists" is not unique but is in err. Therefore "unique"
>> is not a good choice for the term. IMHO. YMMV.
>
> Agreed, it is not unique.  But now consider the following (please !) :
>
>  > <span class="physicist">Albert Einstein</span> ...
>  > <span class="chemist">Dmitry Mendeleev</span> ...
>  > <span class="physician">Madhu Baksh</span> ...
>  > <span class="physicists">J.J. Thomson</span> ...
>  > <span class="physicians">Richard Estall</span> ...
>
> Which (if any) of these should generate a warning in your model
> of the ideal universe ?  "physician" (because it looks like
> a typo for "physicist" ? "physicists" (because it looks like
> an unintentional plural of "physicist") ?  Or "physicians"
> (because it looks like an unintentional plural of "physician" ?

All except J.J. Thomson, as only .physicists has a definition
in <style>. Assuming no definition for the other classes is given
in the omitted parts above first <span>.

> In my experience, all of these are legitimate; I use
> class names that are similar in spelling to one another
> ("physicist", "physician"); I use class names differentiated
> only by number ("physician", "physicians"); and I don't
> think that I am rare in this respect.  So I think
> you are asking a rather a lot by way of A.I. ("artificial
> intelligence") to decide when to issue a warning.

A.I. would be perfect, of course, but I do not hope for that
to happen soon.

A list of the undefined and a list of the unused names, each
with document names and line numbers would quite satisfy me.

> Of course, life is much simpler if you simplify the rules :
> "Issue a warning whenever a class name occurs in the
> HTML XOR CSS".  In which case what might one call such
> a name ?  Not "unique", as you correctly argue; maybe
> "unpaired" : what do you think ?

Close enough as a start.

A correction for the next approximation: a definition in CSS should
be before a usage in HTML. Above, <style> element placed after
J.J. Thomson is an error.  Even two extra errors, an undefined and
an unused name. (I assume that CSS Validator takes care about usages
within CSS.)

"Unpaired" is OK with me. I'm not certain though, how to use it when
I want to separate what I call in my terminology the undefined class
and the unused class. Is "unpaired in CSS" an undefined or an unused
class? I mean, is "chemists" the "unpaired in HTML" and "physician"
the "unpaired is CSS", or the other way around?

> ** Phil.
>

-- 
Vladimir Chukharev
Tampere University of Technology

Received on Tuesday, 17 August 2010 23:07:54 UTC