Skip to content

Help us create more tutorials! Make a donation using the Donate button or become a member using the button below to hide this banner and track your progress.

Selector list – CSS

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 {

}

Demo

Exercises

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

References

Selector list on MDN

Back to: CSS Course > CSS Selectors