Skip to content

Try our new Crash Courses!

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

Select a descendant – CSS

Demo

Summary

To select a descendant of an HTML element, use 2 selectors separated by a space (the first selector represents the parent element and the second selector represents the descendant):

.my-class p {

}

Details

The descendant combinator selects all descendants that match the selector, not just immediate children.

Exercises

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

References

Descendant combinator on MDN

Back to: CSS Reference > CSS Selectors