Skip to content

Try our new Crash Courses!

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

Select a child – CSS

Demo

Summary

To select an immediate child of an HTML element, use 2 selectors separated by a greater than sign (the first selector represents the parent element and the second selector represents the immediate child):

.my-class > p {

}

Details

The child combinator will only select elements that are immediate children of the parent element that match the selector specified.

Exercises

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

References

Child combinator on MDN

Back to: CSS Reference > CSS Selectors