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 child – CSS

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.

Demo

Exercises

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

References

Child combinator on MDN

Back to: CSS Course > CSS Selectors