CSS/Selectors/combinators/child

From W3C Wiki
< CSS‎ | Selectors
Revision as of 22:20, 5 June 2013 by Buttonpresser (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Child combinator A > B

The > (greater than) combinator represents a strict child/parent relationship where element "B" is a direct child element of it's parent element "A".

Syntax

A > B{ preperties }


Point, Note

  • A child combinator is made of the "greater-than sign" (>) character and separates two sequences of simple selectors.
  • For information on selecting the first child of an element, please see the section on the :first-child pseudo-class above.


Example

[style.css]

 h1{
   font-size: 1.1em;
 }
 h1 > .myclass{
   font-style: italic;
 }
 h1 > span > em{
   color: red;
 }


[index.html]

<body>
<h1>This <span class="myclass">headline
is <em>very</em> important</span>
</h1>
</body>

Css3 selectors child.png

CSS defines the child combinator in 8.2. Child combinators.