Grouping Classes in CSS
Let's say we have several classes that paint elements in different colors:
.xxx {
color: green;
}
.yyy {
color: red;
}
Let's say we want to make it so that these classes, in addition to color, also set the font size:
.xxx {
color: green;
font-size: 30px;
}
.yyy {
color: red;
font-size: 30px;
}
Since both classes set the same font size, let's use selector grouping like this:
.xxx {
color: green;
}
.yyy {
color: red;
}
.xxx, .yyy {
font-size: 30px;
}
Simplify your code by using selector grouping:
.eee {
font-size: 20px;
line-height: 1.5;
font-family: Arial;
}
.zzz {
font-size: 30px;
line-height: 1.5;
font-family: Arial;
}
Simplify your code by using selector grouping:
.eee {
font-size: 20px;
text-align: center;
font-family: Arial;
}
.zzz {
font-size: 30px;
text-align: center;
font-family: Arial;
}
.ggg {
font-size: 35px;
text-align: center;
font-family: Arial;
}