[whatwg] scoped style sheets and @-rules

Glenn Maynard glenn at zewt.org
Tue Mar 5 16:04:32 PST 2013

On Mon, Mar 4, 2013 at 11:33 AM, L. David Baron <dbaron at dbaron.org> wrote:

> > You could make the same argument against most of @scoped: you don't need
> to
 > define a scoped style for a class, just use a different class name.
> I think for the rest of @scoped, there are both significant
> performance and encapsulation advantages.

The encapsulation advantages are identical for @font-face and the rest of
@scoped.  Redefining "font-family: serif" to a different serif font using
@font-face is just like redefining <b> to use a brighter color instead of a
bold font.  In both cases, you could argue that you don't need @scoped, but
those arguments are against all of @scoped, not specific to font-family.

One of the big problems with @font-face is that it's not obvious
> whether the @font-face rules should be scoped to:
>   1. font-family declarations in the scoped style sheet, or
>   2. elements in the style sheet's scope, whether the declarations
>      came from the scoped style sheet or not

I think #2 should be obvious to anybody who understands CSS.  In any case,
if a couple people expect #1, that's fine--they'll try it, immediately see
what actually happens and learn that it's #2.  That's the same level of
education that every feature requires.

Option (2) is more reasonably implementable, but I'm not sure it's
> what authors expect.  In particular, it implies changes to fonts
> that are inherited in from outside the scoped style sheet.  It's not
> clear to me that this behavior is useful enough to authors to be
> worth the (still not insubstantial) work of implementing it.

It's natural that I'd be able to make changes to inherited fonts, just like
I can make changes to anything else inherited from other stylesheets.  You
can already change fonts that are already defined (eg. you can redefine
"serif"), that isn't new to @scoped.

This just seems like an arbitrary exception, disabling one random piece of
CSS that's just as useful and natural to use with @scoped as everything

Glenn Maynard

More information about the whatwg mailing list