Attribute class
and id
names can have any value for the HTML syntax (https://www.w3.org/TR/html51/dom.html#classes), while instead for the CSS syntax they can not start for example with a number (https://www.w3.org/TR/CSS2/syndata.html#characters): why?
What is the reason for this (uncomfortable) difference between two syntaxes that are daughters of the same "father" (w3c)?
I saw (https://stackoverflow.com/a/79022/7208844) that the limitation probably depends by a (regex) rule: I do not understand the reason for this rule, since the syntax the html4 managed to do without it (so I suppose that is not a insurmountable physical limit but perhaps unconventional)
$(".1abc").click(function(){
alert("OK with number too");
});
$(".abc").click(function(){
alert("OK");
});
.1abc {
border: 1px solid black;
}
.abc {
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="1abc">number</div>
<div class="abc">no number</div>