What is grouping in CSS and what is it used for?
Grouping means writing several selectors together, separated by commas, so that one set of rules applies to all of them. It avoids repeating the same code.
/* without grouping */
h1 { font-family: Arial; color: #333; }
h2 { font-family: Arial; color: #333; }
h3 { font-family: Arial; color: #333; }
/* with grouping */
h1, h2, h3 {
font-family: Arial;
color: #333;
}
See CSS Selectors.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Selectors |
| CSS Specificity |
| CSS Pseudo-classes and Pseudo-elements |
| Exercises & Assignments |
|---|
| No Content Found. |