Selector - Child Selector

> (World Wide) Web - (W3|WWW) > Selector API

1 - About

A child selector is a selector that select child element in the DOM

A child is a direct descendant. If this is not the case, you may want a descendant selector


3 - List

3.1 - >

A child selector matches when an element is the child of some element. A child selector is made up of two or more selectors separated by “>”.


  • The following rule sets the style of all P elements that are children of BODY:
body > P { line-height: 1.3 }
  • The following example combines descendant selectors and child selectors:
div ol>li p

It matches a P element that is a descendant of an LI; the LI element must be the child of an OL element; the OL element must be a descendant of a DIV. Notice that the optional whitespace around the “>” combinator has been left out.

3.2 - first-child

On this website, this selector will select the link “HOT ITem”

#header .description > a:first-child
web/selector/child.txt · Last modified: 2019/02/09 11:43 by gerardnico