selector-pseudo-element-colon-notation
为适用的伪元素选择器指定单冒号或双冒号表示法。
¥Specify single or double colon notation for applicable pseudo-element selectors.
a::before {}
/** ↑
* This notation */
为伪元素选择 ::
表示法是为了区分伪类(现有元素的子类)和伪元素(未在文档树中表示的元素)。
¥The ::
notation was chosen for pseudo-elements to establish a discrimination between pseudo-classes (which subclass existing elements) and pseudo-elements (which are elements not represented in the document tree).
然而,为了与现有样式表兼容,用户代理还接受 CSS 级别 1 和 2 中引入的先前的伪元素单冒号表示法(即 :first-line
、:first-letter
、:before
和 :after
)。
¥However, for compatibility with existing style sheets, user agents also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line
, :first-letter
, :before
and :after
).
fix
选项 可以自动修复此规则报告的所有问题。
¥The fix
option can automatically fix all of the problems reported by this rule.
选项
¥Options
string
:"single"|"double"
"single"
适用的伪元素必须始终使用单冒号表示法。
¥Applicable pseudo-elements must always use the single colon notation.
以下模式被视为问题:
¥The following patterns are considered problems:
a::before { color: pink; }
a::after { color: pink; }
a::first-letter { color: pink; }
a::first-line { color: pink; }
以下模式不被视为问题:
¥The following patterns are not considered problems:
a:before { color: pink; }
a:after { color: pink; }
a:first-letter { color: pink; }
a:first-line { color: pink; }
input::placeholder { color: pink; }
li::marker { font-variant-numeric: tabular-nums; }
"double"
适用的伪元素必须始终使用双冒号表示法。
¥Applicable pseudo-elements must always use the double colon notation.
以下模式被视为问题:
¥The following patterns are considered problems:
a:before { color: pink; }
a:after { color: pink; }
a:first-letter { color: pink; }
a:first-line { color: pink; }
以下模式不被视为问题:
¥The following patterns are not considered problems:
a::before { color: pink; }
a::after { color: pink; }
a::first-letter { color: pink; }
a::first-line { color: pink; }
input::placeholder { color: pink; }
li::marker { font-variant-numeric: tabular-nums; }