CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
CSS Combat
Target every element inside another element
john010117
Permalink to comment
#
October 2008
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?
soap
Permalink to comment
#
October 2008
Yep pretty sure that will work. Have you tried it?
john010117
Permalink to comment
#
October 2008
Is that seriously the correct syntax? Damn, I'm good. :D Yes, it worked. Thanks.
soap
Permalink to comment
#
October 2008
Good work. I love using it for things like this: #content > *:first-child {margin-top:0;}
It has many great uses that little asterisk.
Add a Comment
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?
It has many great uses that little asterisk.