Common properties when grouping selectors in CSS
It happens that some properties of some selectors are the same, and some are different. In the following code, for example, the headings and paragraph are red, but the paragraph also has other properties:
h2 {
color: red;
}
h3 {
color: red;
}
p {
color: red;
text-align: justify;
font-size: 16px;
}
In this case, you can group the repeating parts, and write down what is not repeated separately:
h2, h3, p {
color: red;
}
p {
text-align: justify;
font-size: 16px;
}
Simplify your code by using selector grouping:
h1 {
text-align: center;
}
h2 {
text-align: center;
color: blue;
}
h3 {
text-align: center;
font-size: 16px;
color: red;
}
Simplify your code by using selector grouping:
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
h3 {
text-align: center;
font-size: 16px;
color: red;
}