This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 10348 - style scoped attribute
Summary: style scoped attribute
Status: RESOLVED WORKSFORME
Alias: None
Product: HTML Checker
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Michael[tm] Smith
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-12 04:11 UTC by John Spaetzel
Modified: 2015-08-23 07:07 UTC (History)
1 user (show)

See Also:


Attachments

Description John Spaetzel 2010-08-12 04:11:13 UTC
The scoped attribute for <style> is a Boolean. In order for it to be used as false. It should not be included in <style>

However... <style> requires type,media, and scoped to be defined.

Therefore making it impossible to validate a false scoped attribute.
Comment 1 Michael[tm] Smith 2010-11-11 18:16:01 UTC
please provide a test case that demonstrates the problem
Comment 2 John Spaetzel 2010-11-11 19:24:25 UTC
(In reply to comment #1)
> please provide a test case that demonstrates the problem

<style type="text/css" media="screen" scoped="true">  Valid
<style type="text/css" media="screen" scoped="false"> Invalid
<style type="text/css" media="screen">                Invalid 

There is no way to validate a false scoped.
Comment 3 Robert Simpson 2010-11-22 18:27:45 UTC
Bug #11362 pointed me here, but since I had already validated pages with "false" scoped styles this issue wasn't quite clear to me. I created a more extensive use case for <style> elements (excluding their use in <noscript>), which can be validated here:

http://validator.W3.org/check?uri=http%3A%2F%2Fwww.ExampleOnly.com%2Fhtml-5%2Fstyle-scoped.html;ss=1

>> There is no way to validate a false scoped.
>> <style type="text/css" media="screen" scoped="true">  Valid
>> <style type="text/css" media="screen" scoped="false"> Invalid
>> <style type="text/css" media="screen">                Invalid 
Since it appears that all three of these cases are for a <style> in the body section, those are the expected results, and also the actual results that I got.

So it appears that now (November 22, 2010) the "false" scoped does validate without error as expected:

Line #6 - <style> with no scoped attribute
     Actual and Expected Results - no error

There is only one case where the actual results differ from the expected results, where a <style> with a scoped attribute validates as if it were set to "false" internally.

Line #44 - <style> with empty string as value of scoped attribute
     Expected Results - Bad value "" for attribute scoped on XHTML element style.
     Actual Results   - no error!

This may be due to XPath treating an empty string as "false" (Quote: "Avoid using a minimized form for boolean attributes, such as selected, or values with an empty string, such as in selected="", which XPath treats as false rather than true." - http://www.HTML-5.com/tutorials/converting-to-html-5.html) - this would need to be validated as "style[@scoped='scoped']" rather than simply "style[@scoped]" (at least when reading it as xHTML - i.e. the XHTML serialization of HTML 5)

Thanks.
Comment 4 Robert Simpson 2010-11-22 18:57:33 UTC
Correction:

The results, both expected and actual, for the earlier use case are (the first two lines here replace the first line in previous comment):

<style type="text/css" media="screen" scoped="scoped"> Valid - line 39
<style type="text/css" media="screen" scoped="true">   Invalid - line 49
<style type="text/css" media="screen" scoped="false">  Invalid - line 54
<style type="text/css" media="screen">                 Invalid - line 34

The scoped attribute _is_ in fact a boolean attribute, and it's possible the original author may have assumed that the values "true" and "false" were appropriate for boolean attributes when they are not. (But then either he should have expected "Valid" for his scoped="false" use case, if those were the expected results in the 2010-11-11 use cases, or got "Invalid" for his scoped="true" use case, if those were the actual results and this had been reported as an issue with the "true" case rather than the "false" one, since "The values 'true' and 'false' are not allowed on boolean attributes".)

Quote (from http://www.HTML-5.com/tutorials/converting-to-html-5.html):

>> Note that the HTML 5 specifications explicitly state that:
>>
>>    The values "true" and "false" are not allowed on boolean attributes.
>>
>> This is because browsers that look at the coded value for boolean attributes
>> would treat the string "false" as false while browsers that only look for the
>> presence or absence of the attribute would treat that code as true, resulting
>> in very inconsistent behavior.
Comment 5 Michael[tm] Smith 2013-06-26 17:53:13 UTC
Yeah, the only valid values for the scoped attribute are "scoped" or the empty string. The spec is clear about that. There's no such thing as a "false scoped attribute". There's no need for one; a style element without a scoped attribute is the same as what a "false scoped attribute" would mean, as far as I can see.