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

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

From: Eduard Pascual <herenvardo@gmail.com>
Date: Mon, 28 Mar 2011 10:43:17 +0200
Message-ID: <AANLkTi=8-pQN6QtxcT-U-_rsaESX7qcfNONk6C=ezXGh@mail.gmail.com>
On Mon, Mar 28, 2011 at 7:23 AM, Jukka K. Korpela <jkorpela at cs.tut.fi>wrote:

> Boris Zbarsky wrote:
>  If you can only affect _some_ parts of the <body> you should in fact
>> be using <style scoped>, no?
> No, because the parts might appear around the <body> so that you cannot use
> any wrapper that contains them all. It would be awkward to use copies of the
> same stylesheet in different <style scoped> attributes.

Yes, it would be awkward. There are lots of things in the web that are
awkward, due to compatibility, interoperability, and implementation cost
If you look closer at the scenario you describe (having control over sparse
parts of the <body>, but not the full document), we don't really want to
enable un-scoped stylesheets there: they could easily interfere with (up to
completely screwing up) the parts of the document you are not supposed to
have control over.

So, yes, @scoped is a suboptimal approach (from an authoring perspective) on
the scenario you described, but at least works. Allowing un-scoped
stylesheets would, in addition to the performance impact, add too much
potential to screw things up.

If you have some idea that:
1) Better addresses this use-case, and
2) would have a reasonable implementation cost
then, by all means, bring it forward.

> By the way, there are undoubtedly cases where you would want to use the
> same scoped stylesheet for different elements, e.g. for different
> <blockquote> elements quoting from the same source. Yet another reason for
> dropping <style scoped> in favor of an attribute referring to an external
> stylesheet.

You can use
<style scoped>
@import url(whatever);
And this even enables you to add some specific styles (be them embeeded or
from another external sheet) on a per-use basis if the need arises. For
example, a long dissertation relying on many quotes may benefit from adding
stronger visual highlights on the <em> elements within the last quote to
reinforce the final conclusion.
Thus there is no reason to drop the feature in favor of something that only
covers a subset of the cases.
The only real benefit of your proposal would be to save typing a few extra
characters. With all other things being equal, less typing would be slightly
better, and hence a good tie-breaking factor. But other things are not equal
among <style scoped> and your suggestion: covering a strictly wider range of
use cases has a lot more weight than saving a few keystrokes.

>  The use case for unscoped <style> outside <head> is if you have full
>> control over the <body> but no control over <head>.
> It is _a_ use case.

Yep, it's just one use case. However, as of now it is *the only* use case
brought forward on the discussion that is justified and not already
addressed by <style scoped>.
If you know of some other case, please feel free to bring it forth, but try
to provide a justification (a reasoning of why it needs to be addressed by
HTML5) and a rationale on how current solutions fail to address it. The case
you have given may be justified, but it is solved with <style scoped>, as
explained above.

Eduard Pascual
Received on Monday, 28 March 2011 01:43:17 UTC

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