使用此 CSS 参考 来浏览 按字母顺序索引 的所有标准 CSS 特性, pseudo-classes , pseudo-elements , 数据类型 , 函数表示法 and at-rules 。您还可以浏览 关键 CSS 概念 和列表化的 按类型组织的选择器 。还包括简要 DOM-CSS / CSSOM 参考 .

基本规则句法

样式规则句法

style-rule ::=
    selectors-list {
      properties-list
    }
					

... where :

selectors-list ::=
    selector[:pseudo-class] [::pseudo-element]
    [, selectors-list]
properties-list ::=
    [property : value] [; properties-list]
					

See the index of selectors , pseudo-classes ,和 pseudo-elements below. The syntax for each specified value depends on the data type defined for each specified property .

样式规则范例

strong {
  color: red;
}
div.menu-bar li:hover > ul {
  display: block;
}
					

For a beginner-level introduction to the syntax of selectors, see our guide on CSS Selectors . Be aware that any syntax error in a rule definition invalidates the entire rule. Invalid rules are ignored by the browser. Note that CSS rule definitions are entirely (ASCII) text-based , whereas DOM-CSS / CSSOM (the rule management system) is object-based .

At-rule syntax

As the structure of at-rules varies widely, please see At-rule to find the syntax of the specific one you want.

索引

注意: The property names in this index do not include the JavaScript 名称 where they differ from the CSS standard names.

- A B C D E F G H I J K L M N O P Q R S T U V W X Z 其它

选择器

The following are the various selectors , which allow styles to be conditional based on various features of elements within the DOM.

基本选择器

基本选择器 are fundamental selectors; these are the most basic selectors that are frequently combined to create other, more complex selectors.

分组选择器

选择器列表 A , B
Specifies that both A and B elements are selected. This is a grouping method to select several matching elements.

组合器

Combinators are selectors that establish a relationship between two or more simple selectors, such as " A is a child of B " or " A is adjacent to B ."

Adjacent sibling combinator A + B
Specifies that the elements selected by both A and B have the same parent and that the element selected by B immediately follows the element selected by A horizontally.
General sibling combinator A ~ B
Specifies that the elements selected by both A and B share the same parent and that the element selected by A comes before—but not necessarily immediately before—the element selected by B .
Child combinator A > B
Specifies that the element selected by B is the direct child of the element selected by A .
Descendant combinator A B
Specifies that the element selected by B is a descendant of the element selected by A , but is not necessarily a direct child.
Column combinator A || B
Specifies that the element selected by B is located within the table column specified by A . Elements which span multiple columns are considered to be a member of all of those columns.

Pseudo

Pseudo classes :

Specifies a special state of the selected element(s).

Pseudo elements ::

Represents entities that are not included in HTML.

另请参阅: Selectors in the Selectors Level 4 specification .

概念

句法和语义

Layout

DOM-CSS / CSSOM

主要对象类型

重要方法

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考