Re: Unscoped <style> found outside the <head>

Funny thing is, while this discussion was going on in email (with which I
just caught up), I was once again running into an instance where I really
wish HTML/CSS had a concept of scope.  Not the same specifics are discussed
here, but a similar underlying notion.  In fact, this is one of the lacks I
found astonishing when first coming fully acquainted with HTML 4 and CSS
(hint: document. formName.elementName should strike you as wrong).

When a page is built from inclusions gathered from multiple sources, there
is (so far as I can tell) no notion of scope.  This bound to be a problem as
mashups become increasingly common.  The notion of scope is not exactly new
in computer science.

The proposal in the WHATWG spec is not exactly what I was hoping to find.
What I was hoping to find was named scopes.  By way of a hypothetical
example:

<link scope="com.google.maps" rel="stylesheet" href="
http://maps.google.com/styles.css" type="text/css">
<style scope="com.google.maps">
... my local enhancements to Google Maps styles ...
</style>

<p>Map of somewhere</p>
<div scope="com.google.maps">
... inclusion from Google Maps ...
</div>

<p>Map of somewhere else</p>
<div scope="com.google.maps">
... inclusion from Google Maps ...
</div>

The styles from the external site could be efficiently and minimally
included once.  (Where in the WHATWG proposal they may be fetched more than
once?)  The use of <div scope=""> makes that scope the current scope.  Class
names resolved within the scoped DIV will look first in the scope namespace
(the usual rules for scopes).

Oddly enough the scoped=boolean attribute triggers the same
candidate-for-refactoring rule as function calls with boolean parameters. :)

Received on Sunday, 27 May 2007 23:24:42 UTC