W3C home > Mailing lists > Public > www-html@w3.org > November 2013

Re: ID/Class Names beginning with numbers

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Wed, 27 Nov 2013 20:35:39 +0200
Message-ID: <52963B7B.3020908@cs.tut.fi>
To: www-html@w3.org
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".

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:06:26 UTC