twitter-bootstrap W3C 验证器、CSS3 和 Bootstrap
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21166019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
W3C validator, CSS3 and Bootstrap
提问by bersude2
I have a site that uses the Twitter Bootstrap framework which renders without errors in all browsers. However, when I plug the main URL of our site into the W3C validator it spits out 1,465 errors, most of which are parsing errors.
我有一个使用 Twitter Bootstrap 框架的网站,该框架在所有浏览器中都没有错误。然而,当我将我们网站的主 URL 插入 W3C 验证器时,它会吐出 1,465 个错误,其中大部分是解析错误。
A few examples:
几个例子:
Parse Error {*zoom:1; Value Error : background-color Too many values or values are not recognized : #3f6998 \000009
解析错误 {*zoom:1; 值错误:背景颜色太多的值或无法识别的值:#3f6998 \000009
I understand the * and \000009 are IE specific, so it is important that these are failing validation?
我知道 * 和 \000009 是特定于 IE 的,所以重要的是这些验证失败?
Is there a validator that takes these into consideration?
是否有一个验证器将这些考虑在内?
回答by Roy M J
You will always get css validation error while using CSS3. Most of the styles(css3) are not valid under w3 rules as of now.. You can simply ignore these errors and move ahead.. Just make sure you do not have any other validation issues other than those with css3 styles. If so you are perfectly fine..
使用 CSS3 时,您总是会遇到 css 验证错误。截至目前,大多数样式(css3)在 w3 规则下无效..您可以简单地忽略这些错误并继续前进..只需确保除了 css3 样式之外没有任何其他验证问题。如果是这样,你完全没问题..
Update :
更新 :
You can try something like this :
你可以尝试这样的事情:
http://jigsaw.w3.org/css-validator/validator?profile=css3&uri=PATH_TO_YOUR_WEBSITE
For eg :
例如:
http://jigsaw.w3.org/css-validator/validator?profile=css3&uri=http://stackoverflow.com
http://jigsaw.w3.org/css-validator/validator?profile=css3&uri=http://stackoverflow.com
Still it will show lot of errors. There are no CSS3 validators yet implemented which is accepted.
它仍然会显示很多错误。目前还没有实现的 CSS3 验证器被接受。
[Updated]
[更新]
URL : https://validator.w3.org/
Please use the official validator.
请使用官方验证器。
回答by Mike W
Here is Bootstrap's explanation for their validation errors:
这是 Bootstrap 对其验证错误的解释:
https://getbootstrap.com/docs/getting-started/#support-validators
https://getbootstrap.com/docs/getting-started/#support-validators
In order to provide the best possible experience to old and buggy browsers, Bootstrap uses CSS browser hacks in several places to target special CSS to certain browser versions in order to work around bugs in the browsers themselves. These hacks understandably cause CSS validators to complain that they are invalid. In a couple places, we also use bleeding-edge CSS features that aren't yet fully standardized, but these are used purely for progressive enhancement. These validation warnings don't matter in practice since the non-hacky portion of our CSS does fully validate and the hacky portions don't interfere with the proper functioning of the non-hacky portion, hence why we deliberately ignore these particular warnings.
为了向旧的和有问题的浏览器提供最佳体验,Bootstrap 在几个地方使用 CSS 浏览器黑客来将特殊 CSS 定位到某些浏览器版本,以便解决浏览器本身的错误。这些 hack 导致 CSS 验证器抱怨它们是无效的,这是可以理解的。在一些地方,我们还使用了尚未完全标准化的前沿 CSS 功能,但这些功能仅用于渐进式增强。这些验证警告在实践中并不重要,因为我们 CSS 的非 hacky 部分会完全验证并且 hacky 部分不会干扰非 hacky 部分的正常运行,因此我们故意忽略这些特定警告。

