- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello Everyone,
Just a curious about the way people structure their class names. Of the following four methods…which do you favor most and why? I generally use the second approach.
**# 1**
.classname {}
**# 2**
.className {}
**# 3**
.class-name {}
**#4**
.class_name {}
That would depend on the class and it’s use.
If one is using modular css.
EG.
.btn
.btn-alert
.btn-advisory
etc/
I use a mixture of underscores and dashes. I agree with Paulie for the modular use. I then throw in an “_” when the variable is multiple words. E.g. “btn-class_name”. Although it seems overly complicated, I do I for the simple reason that when you double click it, it selects the entire “class_name” and ignores anything separated by a “-“. I think the camelCase that you prefer also does that well.
BEM.
> I use a mixture of underscores and dashes
Eeek. That’s a nightmare.
I’m a dashes man through and through.