Hi,
What is grouping in CSS and uses of it ?
Thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hemant KumarPosted Sep 27, 2011, 7:22 AM
Grouping CSS selectors allows you to put the same styles on many different elements without repeating the styles in your style sheet. This means that your style sheet will be smaller and download more quickly.
How to Group CSS Selectors
Separate multiple grouped selectors in the style property by commas. In this example the style will affect the p and div elements:
Any form of selector can be grouped with any other selector. In this example, a class selector is grouped with an ID selector:
And you can group any number of selectors together. In this example, I've grouped four different selectors:
Any Selector Can be Grouped
As you can see from the above examples, any valid selector can be placed in a group. And all elements in the document that match all the grouped elements will have the same style based on that style property.