Re: 'scoped' attribute needs fleshing out

2012-10-26 6:10, Larry Browning wrote:

> Needs to be a valid URI about "scoped" attribute...
>
> Element style is missing required attribute scoped.
>
> |<style type="text/css" media="screen"*>*@import "/css/cmsMods/1.css";</style>|

There are several different issues here.

The error message is somewhat misleading, since the scoped attribute is 
required only when the <style> element is inside the <body> element.

There are problems in the links associated with the error message. I 
guess this is what you refer to with your "Needs to be a valid URI" 
statement. Well, the URI (URL) is valid, just not very helpful:

http://dev.w3.org/html5/spec-author-view/#attr-style-scoped

This refers to a document with the heading "HTML5", subheading "W3C 
Working Draft 11 October 2012". There must be confusion here, since on 
that linked page, there is a link under "Latest Published Version", 
pointing to http://www.w3.org/TR/html5-author/ which carries the 
headings "HTML5: Edition for Web Authors" and "W3C Working Draft 25 
October 2012". On the other hand, on both of these pages, the fragment 
#attr-style-scoped has no impact, since the pages do not contain 
anything that can be referred to that way.

So the link "scoped" points to an outdated document as a whole, not a 
specific location. I suppose it is meant to point to a location where 
the attribute is discussed, such as
http://www.w3.org/TR/html5-author/the-style-element.html#the-style-element
where the attribute is described satisfactorily, although there is also 
an occurrence of "scoped" there that points to
http://dev.w3.org/html5/spec/single-page.html#attr-style-scoped
which is, as the URL suggests, a single-page variant of the dev.w3.org 
version of the HTML5 draft (and currently older than the www.w3.org 
version!). Single-page variants of HTML5 drafts are known as browser 
crushers, as they are large and JavaScript-heavy and often freeze a 
browser badly.

This linking problem is shared by the other links in the message
"Attributes for element style:
Global attributes
media
type
scoped
Also, the title attribute has special semantics on this element."

There seems to be a styling problem, too. At least on my computer (Win 
7; tested Firefox and Chrome), the appearance of the links is partly 
messed up, e.g. "style" has only "tyle" underlines, "media" only "a", 
"type" nothing; screenshot:
http://s11.postimage.org/pbx7053wj/validator.png

 > -- it does not suggest what value can be put in this attribute and using
 > a zero just produces a missing value error.

According to HTML5 drafts, the attribute needs no value. I don't know 
what you tried, but this validates:

<style scoped type="text/css" media="screen">@import 
"/css/cmsMods/1.css";</style>

If a value is specified it must be either the empty string, scoped="", 
or the string "scoped", i.e. scoped="scoped", case-insensitively. This 
follows from the rules for "Boolean attributes":
http://dev.w3.org/html5/spec-author-view/common-microsyntaxes.html#boolean-attributes

On the pragmatic side, the scope attribute is useless for the time 
being. Browsers currently ignore it, applying the rules in a <style> 
element to the entire document, even when the element is inside document 
body. So the effect is different from what one can expect from the 
markup according to HTML5 drafts. (If you add the attribute, the 
validator issues a warning: "The scoped attribute on the style element 
is not supported by browsers yet. It would probably be better to wait 
for implementations.")

Thus, if you want some styles to apply to the entire document, put the 
<style> element inside the <head> element. This works, and it also 
passes validation. Better still, use a <link> element (inside the <head> 
element) to refer to an external style sheet:

<link rel="stylesheet" media="screen" href="/css/cmsMods/1.css">

> NOTE: Whenever possible, give the address of the document you were
> checking.

You were supposed to take that advice, not quote it. Luckily, this time, 
the problem can be inferred. A minimal document to illustrate it is

<!doctype html><title></title>
<div>
<style type="text/css" media="screen">@import "/css/cmsMods/1.css";</style>
</div>

Yucca

Received on Saturday, 27 October 2012 11:03:58 UTC