摘要
这个css3模块描述了css属性的常用值和单位和在css属性定义时使用它们的语法。
css是一种用于描述结构化文档(如 HTML 和 xml)的呈现语言,常见于在屏幕上,在纸上,演讲等。
The value definition field of each CSS property can contain keywords,
data types (which appear between < and >), and information on how they
can be combined. Generic data types ( being the most widely
used) that can be used by many properties are described in this
specification, while more specific data types (e.g., )
are described in the corresponding modules.
每个css属性可以包括keywords, data types(出现在<和>中间),它们如何组合。通用数据类型(被最广泛使用)被最多属性描述 而其他一些更为特定的数据类型(如< spacing-limit >)描述了相应的模块。
1.1. Module Interactions
This module replaces and extends the data type definitions in [CSS21]
sections 1.4.2.1, 4.3, and A.2.
模块的交互
这个模块取代[css21]的相关章节
The syntax described here is used to define the set of valid values
for CSS properties. A property value can have one or more components.
值定义语法
这里描述的语法用于定义一组有效值的CSS属性。属性值可以有一个或多个组件
2.1. Component value types
Component value types are designated in several ways:
组件值类型
组件值类型指定的在几个方面
Some property value definitions also include the slash (/), the comma
(,), and/or parentheses as literals. These represent their
corresponding tokens. Other non-keyword literal characters that may
appear in a component value, such as “+”, must be written enclosed in
single quotes.
一些属性值定义也包括 (/) 逗号 (,)
Commas specified in the grammar are implicitly omittable in some circumstances, when used to separate optional terms in the grammar. Within a top-level list in a property or other CSS value, or a function’s argument list, a comma specified in the grammar must be omitted if:
For example, if a function can accept three arguments in order, but
all of them are optional, the grammar can be written like:
example(first? , second? , third? )
如果一个函数需要三个参数,可以写成这样
example(first? , second? , third? )
Given this grammar, writing example(first, second, third) is valid, as
is example(first, second) or example(first, third) or example(second).
However, example(first, , third) is invalid, as one of those commas
are no longer separating two options; similarly, example(,second) and
example(first,) are invalid. example(first second) is also invalid, as
commas are still required to actually separate the options.
If commas were not implicitly omittable, the grammar would have to be
much more complicated to properly express the ways that the arguments
can be omitted, greatly obscuring the simplicity of the feature.
正确的
example(first, second) or example(first, third) or example(second)
错误的
example(first, , third) is invalid, example(,second) and example(first,)
All CSS properties also accept the CSS-wide keyword values as the sole
component of their property value. For readability these are not
listed explicitly in the property value syntax definitions. For
example, the full value definition of border-color is {1,4} |
inherit | initial | unset (even though it is listed as {1,4}).
所有属性也接受css-wide关键词值作为组件的属性。为了便于阅读 这些都不是明确列出的属性值语法定义。
比如 border-color 的值定义是 {1,4} | inherit | initial | unset
2.2. Component value combinators
Component values can be arranged into property values as follows:
组件值被安排到组件值必须遵循
所有组件遵循顺序
&& 分离两个或多个组件
|| 分离两个或多个options
| 分离两个或多个替代选择
[] 分组
Juxtaposition is stronger than the double ampersand, the double
ampersand is stronger than the double bar, and the double bar is
stronger than the bar. Thus, the following lines are equivalent:
a b | c || d && e f
[ a b ] | [ c || [ d && [ e f ]]]
并列(e f) > && > || > |
For re-orderable combinators (||, &&), ordering of the grammar does
not matter: components in the same grouping may be interleaved in any
order. Thus, the following lines are equivalent:
a || b || c
b || a || c
|| && 中的内容顺序并不重要
2.3. Component value multipliers
Every type, keyword, or bracketed group may be followed by one of the
following modifiers:
For repeated component values (indicated by *, +, or #), UAs must
support at least 20 repetitions of the component. If a property value
contains more than the supported number of repetitions, the
declaration must be ignored as if it were invalid.
每一类型、关键字或相等的组可能是紧随其后的是一个修饰符
感叹号(!),一组表明,集团要求必须至少产生一个值,即使语法组内的物品会让整个内容省略,至少一个组件值不能省略。
2.4. Combinator and Multiplier Patterns
There are a small set of common ways to combine multiple independent
component values in particular numbers and orders. In particular, it’s
common to want to express that, from a set of component value, the
author must select zero or more, one or more, or all of them, and in
either the order specified in the grammar or in any order.
All of these can be easily expressed using simple patterns of
combinators and multipliers:
Note that all of the "any
order" possibilities are expressed using combinators, while the "in
order" possibilities are all variants on juxtaposition.
一个属性值可能有多个组件组成
2.5. Component values and white space
Unless otherwise specified, white space and/or comments may appear
before, after, and/or between components combined using the above
combinators and multipliers.