freeCodeCamp/guide/english/css/selectors/general/child/index.md

702 B

title
Child

Child

The child selector is represented by > and is placed between two selectors: parent > child. It matches any second selector that are children of first selector (the parent). The second selector must be immediate children of the first one.

Here's an example of the syntax:

first selector (parent) > second selector (child) { 
    css declarations; 
}

Here's a code example that matches all immediate span element of with a div parent:

div > span { 
    background-color: red;
}

More Information: