<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22480</bug_id>
          
          <creation_ts>2013-06-26 17:35:33 +0000</creation_ts>
          <short_desc>Spec should clarify if multiple style@scoped elements in a row are valid or not</short_desc>
          <delta_ts>2013-07-03 23:00:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#the-style-element</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael[tm] Smith">mike</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>89903</commentid>
    <comment_count>0</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2013-06-26 17:35:33 +0000</bug_when>
    <thetext>Consider the following example:

  &lt;p&gt;&lt;style scoped&gt;/* first */&lt;/style&gt;&lt;style scoped&gt;/* second */&lt;/style&gt;

Should the second &lt;style scoped&gt; instance be reported as an error or not?
 
The &quot;Contexts in which this element can be used&quot; section for the &lt;style&gt; element says, &quot;If the scoped attribute is present: where flow content is expected, but before any other flow content other than inter-element whitespace&quot;.

The first &lt;style scoped&gt; instance in the example above is flow content, so technically, the second &lt;style scoped&gt; instance in that example is not occurring before any other flow content.

So maybe the text should be updated to say:

  &quot;If the scoped attribute is present: where flow content is expected, but before any other flow content other than inter-element whitespace or another style element with a scoped attribute...&quot;

Or perhaps better yet:

  &quot;If the scoped attribute is present: One or more style elements with a scoped attribute may occur together where flow content is expected, but before any other flow content other than inter-element whitespace...&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89906</commentid>
    <comment_count>1</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2013-06-26 17:46:39 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt;   &quot;If the scoped attribute is present: One or more style elements with a
&gt; scoped attribute may occur together where flow content is expected, but
&gt; before any other flow content other than inter-element whitespace...&quot;

Or maybe even more clear:

  &quot;If the scoped attribute is present: One or more adjacent style elements with a scoped attribute may occur where flow content is expected, but before any other flow content other than inter-element whitespace...&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90180</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-02 23:16:37 +0000</bug_when>
    <thetext>&gt; The &quot;Contexts in which this element can be used&quot; section 

...is non-normative.

The content model side of this just allows &lt;style scoped&gt; anywhere flow content is allowed. The prose for &lt;style&gt; is what restricts it; it says:

# If the scoped attribute is present and the element has a parent element,
# then the style element must be the first node of flow content in its
# parent element other than inter-element whitespace, and the parent
# element&apos;s content model must not have a transparent component.
#
# Note: This implies that only one scoped style element is allowed at a
# time, and that such elements cannot be children of, e.g., a or ins
# elements, even when those are used as flow content containers.

This happens to also be how you interpreted the non-normative &quot;contexts...&quot; text, so it all seems consistent.


But do you have a use case for allowing multiple &lt;style scoped&gt; elements in a row? We can certainly extend the spec to allow it, if necessary...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90207</commentid>
    <comment_count>3</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2013-07-03 01:38:03 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; But do you have a use case for allowing multiple &lt;style scoped&gt; elements in
&gt; a row? We can certainly extend the spec to allow it, if necessary...

I don&apos;t have any specific use case. It&apos;s just that I suspect some authors are going to end up putting multiple &lt;style scoped&gt; elements in a row in their documents, and then wanting it to validate.

As far as why they&apos;d do that, well, some authors do odd things.

One thing that does argue for multiple &lt;style scoped&gt; elements in a row valid is that UAs do actually apply all the styles from multiple &lt;style scoped&gt; elements in a row. e.g., the text in the following example will be rendered in red.

&lt;!doctype html&gt;
&lt;body&gt;
&lt;style scoped=&quot;&quot;&gt;
p { font-style: italic; font-size: 200% }
&lt;/style&gt;
&lt;style scoped=&quot;&quot;&gt;
p { color: red; }
&lt;/style&gt;
&lt;p&gt;Am I red?

I assume the UAs are doing that per-spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90220</commentid>
    <comment_count>4</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2013-07-03 11:20:09 +0000</bug_when>
    <thetext>A better example:

&lt;!doctype html&gt;
&lt;div&gt;
&lt;style scoped=&quot;&quot;&gt;
p { font-style: italic; font-size: 200% }
&lt;/style&gt;
&lt;style scoped=&quot;&quot;&gt;
p { color: red; }
&lt;/style&gt;
&lt;p&gt;Am I red?
&lt;/p&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;Am I red?
&lt;/div&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90287</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-03 22:59:02 +0000</bug_when>
    <thetext>They do work, yeah. I&apos;ll allow it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90288</commentid>
    <comment_count>6</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-07-03 23:00:37 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8035.
Check-in comment: Allow multiple &lt;style scoped&gt; blocks in a row
http://html5.org/tools/web-apps-tracker?from=8034&amp;to=8035</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>