W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2011

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

From: Nicholas Zakas <nzakas@yahoo-inc.com>
Date: Thu, 24 Mar 2011 18:29:11 -0700
Message-ID: <B66541E954ECF146AD8CA69D34A283FF3AA307B047@SP2-EX07VS02.ds.corp.yahoo.com>
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:

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

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:

<div>
    <style scoped>.foo { color: red; }</div>
</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.

Thoughts?

-Nicholas

______________________________________________
Commander Lock: "Dammit Morpheus, not everyone believes what you believe!"
Morpheus: "My beliefs do not require them to."
Received on Thursday, 24 March 2011 18:29:11 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:31 UTC