Re: ID/Class Names beginning with numbers

2013-11-27 20:02, Albert Lunde wrote:

> On 11/27/2013 11:28 AM, Jukka K. Korpela wrote:
>> 2013-11-27 17:45, Thomas BAYER - Web Alliance wrote:
>>
>>> I know my question may sound stupid or might have been answered tons of
>>> times, but here it is : why on earth can't a ID/Class name begin with a
>>> number ?
>>
>> They can, in HTML5, which is what we mostly discuss on this list. (HTML
>> 4 is still the "official" recommendation, but there has been no work on
>> it for years.) And here HTML5 reflects browser practices.
>
> This does differ from HTML 4.01.

Yes it does. In this context, the difference means that HTML 4.01 has 
formal rules that have no impact on reality. But for reasons external to 
HTML, such as CSS syntax and the syntax of URLs (where id values may 
appear), we may consider using mostly HTML 4.01 syntax for id and class 
names. After all, they are supposed to be internal name tokens, not 
visible to users.

> Agreement with previous HTML versions is probably what accounts for the
> definition in the CSS Specifications.

No, it's rather the general CSS syntax. A token that starts with .42 
will be parsed as a real number. To keep CSS parsers simple, .42 is not 
allowed selector - parsing of basic syntactic constructs does not depend 
on context (like selector part of a rules vs. the part where a property 
value is to appear).

> The lack of a versioning mechanism in CSS may be considered a bug or a
> feature....

Yes. In any case, it is a key part of the CSS development process. The 
same really applies to HTML. People have just been misled into thinking 
that old DOCTYPE strings specified the "HTML version being used".

Yucca

Received on Wednesday, 27 November 2013 18:36:17 UTC