File_Submit File_Submit - 3 months ago 9
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?

Answer

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.