treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Target every element inside another element

  • Hi - have another question.

    Normally, when designers want to set a simple CSS reset, they'd do something like this:
    * { margin:0; padding:0; }


    I was wondering if I could do something like this:
    #container * { margin:0; padding:0; }


    What I'm trying to do is remove the margin/padding of every element inside a particular div, but not anything else outside of the div.

    Is this possible?
  • Yep pretty sure that will work. Have you tried it?
  • Is that seriously the correct syntax? Damn, I'm good. :D Yes, it worked. Thanks.
  • Good work. I love using it for things like this: #content > *:first-child {margin-top:0;}

    It has many great uses that little asterisk.