Reputation: 405
I have the following:
.category-2 .content aside {margin-top: 4px;}
.category-3 .content aside {margin-top: 4px;}
.category-4 .content aside {margin-top: 4px;}
How can use one margin-top for all the three categories?
Upvotes: 0
Views: 70
Reputation: 2947
Use the ',' char to share your property to multiple selectors:
.category-2 .content aside,
.category-3 .content aside,
.category-4 .content aside
{
margin-top: 4px;
}
This way of formatting css is called comma separated selector, as @Aaron suggests.
Upvotes: 3
Reputation: 17697
either you write as so
.category-2 .content aside,.category-3 .content aside,.category-4 .content aside {margin-top: 4px;}
or it depends on the rest of the html structure for eg
#category aside { margin-top:4px;}
<div id ="category">
<div class="category-2">
<div class="content">
<aside>
<p>blabla</p>
</aside>
</div>
</div>
<div class="category-3">
<div class="content">
<aside>
<p>blabla</p>
</aside>
</div>
</div>
<div class="category-4">
<div class="content">
<aside>
<p>blabla</p>
</aside>
</div>
</div>
</div>
Upvotes: 1