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.

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 Course > CSS Selectors