CSS3/Selectors/combinators/descendant

From W3C Wiki

Descendant combinator A B

A selector of the form "A B" represents an element "B" that is an arbitrary descendant of some ancestor element "A".

Syntax

A B{ preperties }


Point, Note

  • A descendant combinator is whitespace that separates two sequences of simple selectors.


Example

[style.css]

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


[index.html]

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

The CSS Selectors Level 3 specification defines the Descendant combinator in 8.1. Descendant combinator.