<style> 正文和 W3 标准中的标签
<style> tag within body and W3 Standards
看完这个问题我很困惑:
Using <style> tags in the <body> with other HTML
那里的大多数人都说在正文部分使用样式标签是不好的做法,并且它不符合 W3 标准,但我的理解不同:
http://www.w3.org/TR/html-markup/style.html#style
上面 link 说:
Permitted parent elements:
Any element that can contain metadata elements, div, noscript, section, article, aside
body 元素允许除 'metadata elements' 之外的所有这些元素,但此列表并未说明需要接受所有这些元素才能允许使用 style 标签。所以根据 W3 标准,在 body 中使用样式标签肯定是可以的,因为例如 body 元素允许使用 div?
也许我很久以后才读到这篇文章(5 年过去了),并且由于样式标签的 'scoped' 属性,此规则已更改,所以我想问问我是否错了解释他们的标准与否。
来自您链接到的文档的 front page:
This document has been discontinued and is only made available for historical purposes. For an up to date reference on HTML elements (and more) please consult Web Platform Docs.
一些 草稿 版本 HTML 5 在某些条件下 在正文中允许使用样式元素 。
该功能的设计存在各种问题,它没有进入 HTML 5 的最终版本。
看完这个问题我很困惑:
Using <style> tags in the <body> with other HTML
那里的大多数人都说在正文部分使用样式标签是不好的做法,并且它不符合 W3 标准,但我的理解不同:
http://www.w3.org/TR/html-markup/style.html#style
上面 link 说:
Permitted parent elements:
Any element that can contain metadata elements, div, noscript, section, article, aside
body 元素允许除 'metadata elements' 之外的所有这些元素,但此列表并未说明需要接受所有这些元素才能允许使用 style 标签。所以根据 W3 标准,在 body 中使用样式标签肯定是可以的,因为例如 body 元素允许使用 div?
也许我很久以后才读到这篇文章(5 年过去了),并且由于样式标签的 'scoped' 属性,此规则已更改,所以我想问问我是否错了解释他们的标准与否。
来自您链接到的文档的 front page:
This document has been discontinued and is only made available for historical purposes. For an up to date reference on HTML elements (and more) please consult Web Platform Docs.
一些 草稿 版本 HTML 5 在某些条件下 在正文中允许使用样式元素 。
该功能的设计存在各种问题,它没有进入 HTML 5 的最终版本。