CSS Group Selector
You have read in detail about css selectors in the previous tutorial, in this lesson you will learn about CSS group selector, if more than one selector have same property and value then write those selectors in group .
The properties and values of the declarations of all selectors in the selectors group are the same.
CSS selectors
There are several selectors whose declarations have the same properties and values.
CSS selectors example
color: green;
text-align: center;
}
h2 {
color: green;
text-align: center;
}
p {
color: green;
text-align: center;
}
In this case, it is better to group the selectors to minimize the code.
Use commas (,) to separate selectors in groups.
Example of group selector
color: green;
text-align: center;
}
<h2>This is heading 2</p>
<p>This is a paragraph</p>
This is heading 2
This is a paragraph
We have grouped the element selectors here, in the same way ID selectors and class selectors can also be grouped.
You will learn a lot about CSS selectors, declarations and CSS features in the next tutorials