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

Home Forums CSS Which method is better when setting same style rules, to different elements?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #45166

    So today I caught myself at following. I have many many many elements on a page, some of them have background set to white, I was wondering which method would be better having a class, for example .white-c {background: #fff;} and apply it to elements, or have something like .element1, .element2, .element3 {background:#fff}. Is there any difference with these, which one would work faster maybe?


    I generally don’t like doing classnames for something like this, but it’s probably a personal preference. I’d rather do:

    .name, .other-name, .one-more-name { background: white; }

    Having said that, I wouldn’t group things together for something as simple as a background color (not sure if this was just an example or not).

    If it were something like a button, then by all means a button class makes a lot more sense.

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