CSS Combiner Reference Manual

CSS 组合器

组合器是一种用于解释选择器之间关系的符号。

下表展示了 CSS 中不同的组合器:

名称 符号 例子 例子描述
子组合器 > div > p 选择所有作为 <div> 元素直接子元素的 <p> 元素。
后代组合器 (单个空格) div p 选择所有在 <div> 元素内部的 <p> 元素。
命名空间分隔符 | ns | h2 选择命名空间 ns 中的所有 <h2> 元素。
相邻兄弟组合器 + div + p 选择紧接在 <div> 元素后的第一个 <p> 元素。
选择器列表 , div, p Hausa translation of Select all <div> elements and all <p> elements.
Hausa translation of Subsequent sibling combinator Hausa translation of ~ Hausa translation of p ~ ul Hausa translation of Select all <ul> elements that have a preceding <p> element.