Numbers in class names

Hello all,
I once read an article that was explaining a method that allowed css class (and id, i think) names to start with a number (0-9)

Of course, I didn’t save it or make note of what it was said… :blush:

I don’t recall how, but I remember it being something like an escape character. For example
in some programming language to drop a carriage return in a print statement?

Possibly something like class=“\1” and then .1{ /* styling goes here */ }

Can anyone verify the above or have any clue on how to achieve this (legally)

Thanks in Advance,
Team 1504

I think this might help. Specifically, the second point:

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. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier “B&W?” may be written as “B\&W\?” or “B\26 W\3F”.

and the note in green at the bottom:

Note: Backslash escapes are always considered to be part of an identifier or a string (i.e., “\7B” is not punctuation, even though “{” is, and “\32” is allowed at the start of a class name, even though “2” is not).

This page with examples should also help.

ah okay. Thank you, that helped.
But I still have some quesitons with the second example:

In this : “.\0034”, do the numbers after the slash stand for something (like an econding)?

Because for the first 4 examples, I noticed a pattern: anything after the “\” and before the 3 doesn’t matter in the identifiter name…
For example: .\32\32\32\32 = .222 & .\033\033\033\033 = .333
so based on that logic:
.\32\32\32\32 and .\02432\02432\02432\02432 =.222 ?

It is the second to last and the last that break my pattern. They seem to be using \ and a specific series of digits to represent a character or characters. Or that could be because there is no 3 in either of them?
.\06B0 = .ڰ because there is no 3 in the sequence. where as .\06B032 equals .2 ?

+Team 1504
Am I on the right path or did I mess something up by noticing a patter?

See ISO 10646 http://www.unicode.org/roadmaps/smp/

Ah, so because there were letters invovled, it corresponded to a character (symbol / letter)

But when it is just .\anynumbers3numbers, all the numbers after the 3 are then part of the class name as in they equal .numbersAfter3

Also, is this fully supported? I know this is just 2.1 class names, but its an around the box idea, so does not browser not support it or well?

+Team 1504

Actually the link http://www.unicode.org/roadmaps/bmp/ might have been the slightly better link. Basically if the OS and browser supports Unicode it will try based upon fonts installed, etc.

The usual HTML 4.01 suspects: http://www.w3.org/TR/html4/sgml/entities.html#iso-88591

The backslash basically cancels anything that isn’t a “hexadecimal digit” so it strips the item after the backslash, or any code point zero, if it’s not a hexadecimal digit, e.g. .\0034\0034\0034\0034 hence .4444 because those 4 digits were before the backslash: “\” save the last 4, which makes a 4-digit number.

Thus the ڰ ARABIC LETTER GAF WITH RING 06B0 which is a U+06B0 thus doesn’t get stripped as its in a a hexadecimal format. This might make it easier to see: http://en.wikipedia.org/wiki/List_of_Unicode_characters

apologies for not replying in a while, but I haven’t had time to try any of this :lol:

I have been seriously busy. However, and of course, I sincerely appreciate all the help!

And I will get back to your probably later next week :slight_smile:

+Team 1504