Is using camelCase in CSS ids or classes ok or not?

James P. picture James P. · Jul 10, 2012 · Viewed 41.5k times · Source

Question is in the title. I'm used to using camelcase in development and, since there are crossovers with design, was wondering if there are any technical reasons (regardless of opinions) against using it in HTML. Thanks in advance for your replies.

Answer

srigi picture srigi · Jul 19, 2013

There is one technical limitation if you use camelCase identifiers in your CSS - the |= selector specifier:

<form class="registration"></form>
<form class="search-movies"></form>
<form class="search-actress"></form>

To match only search forms, you can write:

[class|="search"] { font-size: 150% }

You cannot do this with camelCase class names.