[whatwg] Why is @scoped required for <style> as flow content?

Nicholas Zakas nzakas at yahoo-inc.com
Thu Mar 24 18:29:11 PDT 2011

HTML5 currently requires the scoped attribute for <style> elements when placed in an area where flow content is expected. This strikes me as strange since it's not backwards compatible with HTML 4 nor indicative of how browsers deal with <style> elements as flow content today. Put quite simply, this:

    <style>.foo { color: red; }</style>

works just fine in browsers today, and the style information is applied to the entire document. This is considered invalid HTML5 (tested using html5.validator.nu) because the scoped attribute is missing. Fixing the issue results in:

    <style scoped>.foo { color: red; }</div>

However, this is not equivalent to the previous code because the styles are now confined to the subtree of the enclosing <div> element.

It seems like the scoped attribute should be optional when <style> is used as flow content and disallowed when used in meta content. That way, you're adding the new functionality of limiting styles to a subtree while also ensuring that the spec reflects current browser behavior. Pleasant side effect is that everyone with <style> as flow content will have on less validation error to worry about.



Commander Lock: "Dammit Morpheus, not everyone believes what you believe!"
Morpheus: "My beliefs do not require them to."

More information about the whatwg mailing list