Skip to content

Try our new Crash Courses!

Become a member using the button below to hide this banner and gain access to our new Crash Courses.

Selector list – CSS

Demo

Summary

To target multiple selectors at once in CSS, list out the selectors and separate them using commas:

h1, .my-class, #my-id {

}

Details

To target multiple selectors at once in CSS, list out the selectors and separate them using commas. You can use the same type of selector or mix different types of selectors in the list. For example, here’s a list of type selectors:

h1, h2, p {

}

Here’s an example that mixes selectors:

h1, .my-class, #my-id {

}

Exercises

Recreate the CSS code from the Demo section in your CSS file.

References

Selector list on MDN

Back to: CSS Reference > CSS Selectors