Reputation: 18602
I want to apply style for every thing inside div
example :
<div id="myDiv">
<h1>...</h1>
<p>...</p>
<img ... />
<div>
<a>...</a>
<a>...</a>
</div>
<button>...<button>
<div>
css :
#myDiv {
padding : 5px;
color : #2B2B2B;
font-weight : 700;
}
I want all element inside the div to have same style as div
the query I'm looking for is something like this #div , #div MY_ALL_ELEMENTS
maybe this dumb question , but I'm newbie to css
Upvotes: 0
Views: 1367
Reputation: 67778
In your case, that selector would be #myDiv * { ... }
, which selects ALL elements inside #myDiv
(not only the direct children elements, but also children of children etc.)
#myDiv * {
padding : 5px;
color : #2B2B2B;
font-weight : 700;
}
<div id="myDiv">
<h1>bla</h1>
<p>bla bla bla bla</p>
<img bla />
<div>
<a>bla bla </a>
<a>bla bla bla</a>
</div>
<button>bla</button>
<div>
Upvotes: 1
Reputation: 19764
Yes, a universal selector *
. For all direct discendants, use the child combinator #div > *
.
Upvotes: 3