CSS validation not validating

余生颓废 提交于 2019-12-24 05:35:15

问题


/* ** ** 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]


回答1:


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:

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?




回答2:


::-moz-selection

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




回答3:


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



来源:https://stackoverflow.com/questions/4931040/css-validation-not-validating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!