Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. CSS
  3. Descendant combinator

Descendant combinator

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⁩.

Thedescendant 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 (parent, parent's parent, parent's parent's parent, etc.) element matching the first selector. Selectors that utilize a descendant combinator are calleddescendant selectors.

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

The descendant combinator is technically one or moreCSS 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

css
selector1 selector2 {  /* property declarations */}

Examples

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>

Result

Specifications

Specification
Selectors Level 4
# descendant-combinators

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp