Mar
26

Don’t start your classes or IDs with a number

By Sam  //  All browsers  //  No Comments

Might not be an obvious one for people approaching CSS from a design background rather than a programming one.

The browser will not pick up your styles if your element’s class or ID starts with a number.

If you’re wondering why the browser is ignoring the styles you’ve set, that might be why!

The same goes for hyphens and underscores, the only non-alphanumeric characters allowed in classes and IDs. The CSS spec states that hyphens and underscores should only be used for vendor-specific extensions (for example, if you’ve ever seen -moz-attribute used).

Leave a comment

Sponsored links