File_Submit File_Submit - 2 months ago 4
CSS Question

CSS: one property for multiple classes

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?


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.