CSS 验证未验证

发布于 2024-10-16 18:53:21 字数 366 浏览 0 评论 0原文

/* ** ** custom select color ** ** */
::selection {
 background: #525252; /* Safari */
}
::-moz-selection {
 background: #525252; /* Firefox */
 color:#fff;
}

上面的代码没有通过W3C验证器,但我无法理解其原因。

返回以下错误:

伪元素::selection不能 出现在上下文 css21 中 [选择]

伪元素 ::-moz-selection 不能出现在此处 上下文 css21 [-moz-selection]

/* ** ** custom select color ** ** */
::selection {
 background: #525252; /* Safari */
}
::-moz-selection {
 background: #525252; /* Firefox */
 color:#fff;
}

The above code is not passing the W3C validator, but I can't understand the reason for it.

The following error is returned:

The pseudo-element ::selection can't
appear here in the context css21
[selection]

The pseudo-element
::-moz-selection can't appear here in
the context css21 [-moz-selection]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

萤火眠眠 2024-10-23 18:53:21
1        The pseudo-element ::selection can't appear here in the context css21 [selection]
4        The pseudo-element ::-moz-selection can't appear here in the context css21 [-moz-selection]

没什么好担心的,第一个是抱怨,因为它正在针对 CSS2.1 进行测试,第二个,正如 Kyle 所建议的,是因为 -moz 前缀

要消除第一个“错误”,请执行以下操作:

在此处输入图像描述

单击更多选项链接并将配置文件更改为 CSS 3。

这不能消除第二个错误,并且可能应该学会忽略此类错误。我知道这听起来很痛苦,除非有人可以提供替代建议?

1        The pseudo-element ::selection can't appear here in the context css21 [selection]
4        The pseudo-element ::-moz-selection can't appear here in the context css21 [-moz-selection]

That's nothing to worry about, the first one is complaining because it's being tested against CSS2.1, and the second, as Kyle suggested, is because of the -moz prefix

To silence the first "error", do the following:

enter image description here

Click on the more options link and change the profile to CSS 3.

This can not silence the second error, and should probably learn to ignore this kind of errors. I know it sounds a big of a pain, unless anyone can offer an alternative suggestion?

肩上的翅膀 2024-10-23 18:53:21
::-moz-selection

即使在 CSS 级别 3 下,Mozilla/Webkit 特定的 CSS 元素也不会验证。

::-moz-selection

Mozilla/Webkit specific CSS elements do not validate even under CSS level 3.

左耳近心 2024-10-23 18:53:21

今天,即使是 ::selection 也会出现问题,因为它已从 CSS3 中删除。

Today you have a problem even with ::selection because it was dropped from CSS3.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文