Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

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