HTML5 范围属性使用什么做法
我今天使用 w3c 验证器验证我的 HTML5 页面,并收到一条错误消息,指出样式标记必须具有范围属性(如果它不在 head 部分)。因此,我将范围属性添加到样式标签中,现在我从验证器收到此警告,
浏览器尚不支持样式元素上的范围属性。等待实施可能会更好。
那么是哪一个呢?使用作用域属性,还是不使用?如果我不这样做,那么我会收到验证器的错误,如果我这样做,我会收到一条警告,说不要使用它。
I went to validate my HTML5 page today using the w3c validator and recieved an error message saying the style tag must have the scoped attribute if its not in the head section. So I added the scope attribute to my style tag and now I am getting this warning from the validator,
The scoped attribute on the style element is not supported by browsers yet. It would probably be better to wait for implementations.
So which is it? Use the scoped attribute, or dont? If I do not then I am getting an error from the validator, if I do than I am getting a warning saying not to use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你在头部之外有一个样式元素,验证器会向你抱怨。不支持范围界定,您不应该出于验证原因这样做,它在 HTML5 中具有非常明确的含义,并且 WebKit 很快就会支持它。
另一方面,浏览器根本不关心你的样式元素在哪里。因此,请随意将它们放在您需要的地方。 (假设你有充分的理由将它放在头部之外......我很好奇......)
无论如何,这是验证器如何不反映浏览器现实的另一个例子。 :)
The validator will bitch at you if you have a style elem outside of the head. Scoping isnt supported and you should NOT do it for validation reasons, it has very explicit meanings in HTML5 and WebKit is soon landing support for it.
Browsers, on the other hand, don't give a shit about where your style elements are. So feel free to put them where you have to. (Assuming you have a good reason to put it outside of the head... which I'm curious about..)
Anyway, yet another example of how the validator does not reflect the reality of browsers. :)