Streaming live at 10am (PST)

Nested Divs or Combo classes? What's your opinion!

#1

Sort of a random question. I’m trying to make my structure look nice. It kind of bothers me that combo classes are sort of not universalt. For example I might have a sort of bottom/top padding I easily want to be able to apply to a section. Well long story short, I’ve come to the point where I tend to nest divs just to be able to apply a specific class to that div.

What’s your opinion? Is this really stupid. How do you do? Do you make combo classes instead?

Ps. I use both methods. The nesting of divs I mainly use for the section/container/wrapping structure.

#2

Nesting divs is a healthy and good practice technique. There is no loss of efficiency when you nest. it’s very good for compatibility accros browsers to nest and spread the styling accross a series of nested divs. Don’t hesitate to nest, that’s perfectly fine and will help you down the road to maintain and update your site.

#3

Nesting is one good way. I personally use multi-classes. I set up auxillary classes that would do one thing like create bottom margin for example. Then just add this class to any element when necessary.