What practice to use for HTML5 scoped attribute

回眸只為那壹抹淺笑 提交于 2019-12-13 06:16:29

问题


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.


回答1:


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. :)



来源:https://stackoverflow.com/questions/6751922/what-practice-to-use-for-html5-scoped-attribute

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