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.

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