Question about <style> and <style scoped>

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
User avatar
Pim
Posts: 2215
Joined: May 17th, 2004, 2:04 pm
Location: Netherlands

Question about <style> and <style scoped>

Post by Pim »

What's the official status on <style scoped> at the moment?

According to the MDN page on style, browser support is abysmal, so it shouldn't be used on public webpages because of incompatibility issues.
That much is clear. Not asking about that.

But how about the official definition?
The MDN page says you can use <style> in the head, and <style scoped> in the body (or more formally, anywhere that flow content is possible).
The W3C on the other hand, makes no such distinction; it says you can use <style> in "any element that can contain metadata elements, div, noscript, section, article, aside" and doesn't mention that scoped changes the content category.

So am I missing something?

Oh, I can't get the W3C validator to work with <style scoped>. A quick and dirty test like this

Code: Select all

<!DOCTYPE html>
<title>test</title>
<body>
<p>test 1</p>
<div>
  <style scoped>p {background:lime}</style>
  <p>test 2</p>
</div>
is supposed to validate without errors as far as I understand. But the validator complains about the <style> in the <div>. (Note that it doesn't complain about the scoped attribute.) Again, am I missing something?
Groetjes, Pim
User avatar
Frenzie
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium
Contact:

Re: Question about <style> and <style scoped>

Post by Frenzie »

The validator follows the W3C specification and doesn't necessarily reflect the latest WHATWG (or even W3C) drafts, so there's no surprise there. However, a quick search on the WHATWG spec issues shows that it's been removed because "it's a feature with only one implementation, and no positive signals from any other vendors." A pity, because this sounds potentially quite useful.
Intelligent alien life does exist, otherwise they would have contacted us.
User avatar
Pim
Posts: 2215
Joined: May 17th, 2004, 2:04 pm
Location: Netherlands

Re: Question about <style> and <style scoped>

Post by Pim »

Oh, it seems you're right. When doing more searching, I also found that the scoped attribute (and the possibility to use <style> in the body) is no longer there in the latest version of the W3C's working draft for HTML (the 2016-06-02 version).

That's definitely a recent development though; it was still present in the previous working draft, from 2016-03-10.

So, thanks! And yes, I was missing something.
Groetjes, Pim
AlfonsoML
Posts: 387
Joined: September 6th, 2006, 1:39 pm
Contact:

Re: Question about <style> and <style scoped>

Post by AlfonsoML »

Just for reference, in the future don't bother looking at W3C, go straight to the source and look at the WHATWG because there's where all the work is done and the browser vendors are there.
User avatar
Pim
Posts: 2215
Joined: May 17th, 2004, 2:04 pm
Location: Netherlands

Re: Question about <style> and <style scoped>

Post by Pim »

But I've always gone to the W3C first. Back in the bad old days when everything was a mess, the W3C stepped in and helped develop real standards. Then after many years of stability, the WHATWG came and said, hey, you're not changing things quickly enough, we need more change! And I'm not convinced that is all good.

Also, I'm not sure if I have forgiven the WHATWG for attempting to un-deprecate <font>.

So if it ever comes to a civil war between them (and let's hope it remains civil!) I'll have to side with the W3C.

Oh, don't get me wrong, I'm not fond of everything the W3C does either. Take "HTML 5.1" for an example. But still.
Groetjes, Pim
AlfonsoML
Posts: 387
Joined: September 6th, 2006, 1:39 pm
Contact:

Re: Question about <style> and <style scoped>

Post by AlfonsoML »

It's not about what you like or not.
The fact is that the current HTML spec from W3C is a fork (usually outdated) of the version from WHATWG.
User avatar
Pim
Posts: 2215
Joined: May 17th, 2004, 2:04 pm
Location: Netherlands

Re: Question about <style> and <style scoped>

Post by Pim »

Let's just agree to disagree. On the one hand, it sounds like you're proving my point - the WHATWG is changing things faster than the W3C likes to, and that's too fast for any reasonable stability in my eyes.

On the other hand, the W3C has, for example, deprecated the hgroup element by now, of which the WHATWG still seems to think it's a good idea.

So let's just agree to disagree, OK?
Groetjes, Pim
Post Reply