W3C home > Mailing lists > Public > www-style@w3.org > September 1999

RE: Embedded style and style wrappers (RE: New WD: CSS3 selectors)

From: Jelks Cabaniss <jelks@jelks.nu>
Date: Sun, 26 Sep 1999 17:32:41 -0400
To: "Bert Bos" <Bert.Bos@sophia.inria.fr>, <www-style@w3.org>
Message-ID: <NBBBICMNIPCICMKJECCBIEPFCOAA.jelks@jelks.nu>
Bert Bos wrote:

> > Speaking of embedded, I assume there's no plan of using "embedding"
> > (as we can do with HTML docs) CSS inside XML docs? ...
>
> In principle, you can already do that with the processing instruction
> (PI), if you use a fragment-ID as the URL:
>
>     <?xml-stylesheet type="text/css" href="#x12" ?>
>     ...
>     <STYLE ID="x12">
>       STYLE { display: none }
>       /* some more CSS here */
>     </STYLE>
>     ...
>
> It is somewhat indirect, and the meaning of the STYLE element is
> hidden inside a PI, but if all you want is a way to render the
> document, this trick should work.

Fascinating, thanks!  I never thought of *linking* to an ID within the same
document, but it makes sense. It also works in IE5 and Gecko, with the following
caveats:

1)  If you use the mechanism as expressed above, you *will* see the CSS
declarations despite the "display: none", because the STYLE element is already
"open" as the document is being progressively rendered.  With IE5, you can say

	<STYLE ID="x12" style="display: none"> ... </STYLE>

because evidently it hardwires the ID, CLASS, TITLE, and STYLE attributes a la
HTML 4.0.  Gecko, OTOH, does not honor an inline attribute named "style" in an
XML document.  IE5 is thus more "convenient", but Gecko is merely acknowleging
that there is no mechanism to map .classname to something which in HTML we call
CLASS.  IMO, there should be some kind of formal mechanism to "map" a CLASS
attribute to .classname, <element styleAttr="inline style rule[s]", etc.

2)  If you enclose the STYLE element's contents in comments (a la HTML authoring
for CSS-challenged browsers and indexing agents)

	<STYLE ID="x12"><!--
		/* unrendered declarations here */
	--></STYLE>

it works in *both* IE5 and Gecko: the contents of STYLE are not rendered, but
the rest of the document is, according to the embedded style rules.

/Jelks
Received on Sunday, 26 September 1999 17:34:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:00 GMT