後裔選擇器

簡介

組合符號 (代表空白, 或更精準地說,代表一或多個空白字元) 結合了兩種選擇器,選擇了只有當第二個選擇器的目標為第一個選擇器目標的後裔時的元素,後裔選擇器跟子選擇器相似,但是不要求披對的元素要是嚴格是父子關係。

語法

selector1 selector2 { style properties }

範例

span { background-color: white; }
div span { background-color: DodgerBlue; }
<div>
  <span>Span 1.
    <span>Span 2.</span>
  </span>
</div>
<span>Span 3.</span>

Specifications

Specification Status Comment
Selectors Level 4
The definition of 'descendant combinator' in that specification.
Working Draft  
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

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ?