Is there a reason why CSS doesn't support ids and classes, starting from numbers? -


i noticed css properties aren't applied if id or class starts number. example, none of following work:

.1ww{     /* properties here */ } 

and

.1{     /* properties here */ } 

and

#1{     /* properties here */ } 

and

#1ww{     /* properties here */ } 

why doesn't css support ids or class names, starting numbers? (javascript, example, works numeric ids , classes)

in fact, specification states classes starting number interpreted dimension [1]:

css2 parses number followed identifier dimension token (i.e., unknown unit), css1 parsed number , identifier. means in css1, declaration 'font: 10pt/1.2serif' correct, 'font: 10pt/12pt serif'; in css2, space required before "serif". (some uas accepted first example, not second.)

and since don't know dimensions introduced in future, dimensions not exist in css parsed unknown dimensions:

in css1, class name start digit (".55ft"), unless dimension (".55in"). in css2, such classes parsed unknown dimensions (to allow future additions of new units). make ".55ft" valid class, css2 requires first digit escaped (".\35 5ft")

you can use class starting numbers escaping first digit, valid according w3c css validator. check out plunkr.

[1] appendix g. grammar of css 2.1


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -