Lesson 4, Topic 1
In Progress

CSS grouping elements

John 23/11/2024
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;
}
Social Community We would like to show you notifications for the latest news and updates.
Dismiss
Allow Notifications