camelCase CSS or Not?

I’ve always tried to stay away from camelCase CSS selectors in the past, but recently someone asked me why… and to be honest… I don’t know. I like camelCase and use it pretty much everywhere else frequently, but not in CSS.

Do you use it or do you try to stay away from it? Why or why not? Do you do something different?


.camelCaseClass { display: none; }
.not-camel-case-class { display: block; }

Funny enough, I do the same. The reason probably is because CSS class names are case insensitive and thus it is harder to spot accidentally creating camelcaseclass (even though it isn’t) from camelCaseClass from CamelCaseClass (even though it isn’t) and likely overwriting something you made earlier.

Plus I just find not-camel-case-class to read easier both in the CSS and in the underlying code.

Call it personal preference, but you’re not alone.


I personally like using dashes more. For a few reasons. Typing wise, it’s more awkward for me to capitalize a letter. More room for error (and if you do make that error, it’s more difficult to spot a missing - than an uncapitalized character.)

Also it’s easier to read dashes.


I was googling around and the only thing I could find as to why you don’t want to to use it, is because CSS elements use dashes. Like font-size or border-width and it’s best not to mix the styles. This makes sense, but I think it’s kind of a weak argument for Class and ID naming schema.


I guess this makes sense. I figured asking this question would lead me to another duh moment. I seem to be having a lot of them today.

StackOverflow Link

1 Like

Css is case insensitive for all things under its control but ids and classes must match case exactly in order to work.

1 Like

Yeah, I got that from @mawburn’s SO link. So I definitely had a misconception of CSS to some degree. :smile:

1 Like

I have a strict rule of keeping everything in CSS lower case, as it avoids unnecessary case-related mistakes. It also looks a lot neater to me.


I think that what matters is that you’re consistant. Whatever you choose is fine. Personally, I try to use lower case and avoid more than one word names. But if I have to, yes, I do use camel case


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.