Lesson 4, Topic 1
In Progress

CSS grouping elements

john May 20, 2019
Lesson Progress
0% Complete

If you have elements with the same style definitions, like this:

h1 {
  text-align: center;
  color: red;
}

h2 {
  text-align: center;
  color: red;
}

p {
  text-align: center;
  color: red;
}

It will be better to group the selectors, to minimize the code.To group selectors, separate each selector with a comma. In the example below we have grouped the selectors from the code above:

Example

h1, h2, p {
  text-align: center;
  color: red;
}