Reputation: 169
If we speak micro optimization of javascript and CSS. Does it matter if the class or ID contains numbers? Just a silly thought, since I don't know how it works behind the scenes.
Will forexample:
#d1
#d2
#d3
and
.d1
.d2
.d3
Be better/worse than:
#da
#db
#dc
and
.da
.db
.dc
I know that you can't start a class or ID with a number...
Upvotes: 1
Views: 615
Reputation: 19228
Use reasonable names so that programmers can maintain that. For Example if you are displaying a generic error message you can use class error-message
which the programmers understand.
You can save bandwidth by using Http Compression. Also javascript compressor replace the variables names into a small variables with length of 1-3. You can also configure web server to compress static content (js, css), in addition to minimization done by compressor.
Upvotes: 1
Reputation: 20788
It doesn't matter at all. They're all treated as strings of characters. As an example, look at the WebKit source code.
inline const AtomicString& Element::getIdAttribute() const
{
return fastGetAttribute(document()->idAttributeName());
}
Upvotes: 2
Reputation: 28554
I use numbers in ids all the time to specifically address items of a ul list for instance. There is no problem with that at all.
<ul>
<li id="user_1">User: Chris</li>
<li id="user_2">User: Steve</li>
<li id="user_3">User: Frank</li>
</ul>
Upvotes: 0