Unsere Freiwilligen haben diesen Artikel noch nicht in Deutsch übersetzt. Machen Sie mit und helfen Sie, das zu erledigen!
Sie können den Artikel auch auf English (US) lesen.

The descendant combinator — typically represented by a single space ( ) character — combines two selectors such that elements matched by the second selector are selected if they have an ancestor element matching the first selector. Selectors that utilize a descendant combinator are called descendant selectors.

/* List items that are descendants of the "my-things" list */
ul.my-things li {
  margin: 2em;
}

The descendant combinator is technically one or more CSS white space characters — the space character and/or one of four control characters: carriage return, form feed, new line, and tab characters — between two selectors in the absence of another combinator. Additionally, the white space characters of which the combinator is comprised may contain any number of CSS comments.

Syntax

selector1 selector2 { /* property declarations */ }

Example

CSS

li {
  list-style-type: disc;
}

li li {
  list-style-type: circle;
}

HTML

<ul>
  <li>
    <div>Item 1</div>
    <ul>
      <li>Subitem A</li>
      <li>Subitem B</li>
    </ul>
  </li>
  <li>
    <div>Item 2</div>
    <ul>
      <li>Subitem A</li>
      <li>Subitem B</li>
    </ul>
  </li>
</ul>

Result

Specifications

Specification Status Comment
Selectors Level 3
The definition of 'descendant combinator' in that specification.
Recommendation  
CSS Level 2 (Revision 1)
The definition of 'descendant selectors' in that specification.
Recommendation  
CSS Level 1
The definition of 'contextual selectors' in that specification.
Recommendation Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support

Yes

611

121 Yes Yes Yes
A >> B syntax No No No No No10 — 11.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes

Yes

611

Yes4 Yes Yes Yes
A >> B syntax No No No No No10 — 11.1 No

1. >>> is aliased to this selector since its use as the 'shadow-piercing descendant combinator' was deprecated.

Schlagwörter des Dokuments und Mitwirkende

Schlagwörter: 
Zuletzt aktualisiert von: kayhuba,