子孫結合子

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

子孫結合子 (descendant combinator) — 通常は単一の空白文字 (" ") で表される — は 2 つの CSS セレクターを結合し、 1 つ目のセレクターに一致する要素が祖先 (親、親の親、親の親の親、など) となっている 2 つ目のセレクターに一致します。子孫結合子を利用したセレクターは 子孫セレクター と呼ばれます。

css
/* "my-things" リストの子孫のリスト項目 */
ul.my-things li {
  margin: 2em;
}

子孫結合子は、技術的には他の結合子がない 2 つのセレクターの間にある 1 つ以上の CSSホワイトスペース文字 ― 空白文字や 4 種類の制御文字 (復帰、ページ送り、改行、タブ文字) のうちの 1 つ ― です。さらに、結合子としてのホワイトスペース文字には任意の数の CSS コメントを含めることができます。

構文

css
セレクター1 セレクター2 {
  /* プロパティ宣言 */
}

CSS

css
li {
  list-style-type: disc;
}

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

HTML

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>

結果

仕様書

Specification
Selectors Level 4
# descendant-combinators

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Descendant combinator (A B)

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報