Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS What is your naming method for classes?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #46175
    Rugg
    Participant

    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 {}

    #141794
    Paulie_D
    Member

    That would depend on the class and it’s use.

    If one is using modular css.

    EG.

    .btn
    .btn-alert
    .btn-advisory

    etc/

    #141845
    birdsong
    Member

    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.

    #141886
    Kitty Giraudel
    Participant

    BEM.

    #141931
    TheDoc
    Member

    > I use a mixture of underscores and dashes

    Eeek. That’s a nightmare.

    I’m a dashes man through and through.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.