W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Opera's Proposal for :context Selector

From: Bert Bos <bert@w3.org>
Date: Fri, 11 Jul 2008 16:56:42 +0200
To: www-style <www-style@w3.org>
Message-Id: <200807111656.42600.bert@w3.org>

On Thursday 10 July 2008 22:03, Lachlan Hunt wrote:
> Hi,
>    This is a proposal for a new :context pseudo-class designed to
> match the context node of a query, where the the scope of elements
> that match a given Selector is constrained to be within a subtree
> rooted by a particular node.

If I understand correctly, the underlying goal is to better support 
subdocuments: a document with its own style sheet inside another 
document.

I think there is an error in the reasoning that led to this proposal.

The smallest unit on the Web is a document. (In programmer's terms, it's 
a "compilation unit.") For text or compound documents, that is usually 
an HTML file. Such a file has a name (URL), content (BODY) and metadata 
(HEAD), the latter contains the title, the style sheets, document 
relations, scripts, and some other things.

If you find that you have a "subdocument" that needs its own stylesheet, 
you'll soon find that it also needs its own URL, title and other 
metadata. The subdocument looks very much like an HTML file. In fact, 
it *is* an HTML file.

HTML is a format for compound documents. If your subdocument is a JPEG 
image, you add an IMG (or any of its aliases, OBJECT, VIDEO, EMBED, 
etc.) to seamlessly include the image in the document.

If the subdocument is HTML, you do the same!

Of course, there is a lingering problem in practice: most browsers still 
have difficulties with certain kinds of documents. Although images are 
seamlessly embedded, text files and HTML files are not. Where the 
browser automatically uses the right height for an image, it uses an 
arbitrary 150 px for an embedded text file. Almost impossible for an 
author to make compound documents look seamless with such a browser...

But the fix is not to add new mark-up to HTML or new 
selectors/properties to CSS. All the required syntax is already there. 
Neither HTML nor CSS needs to be made more complex. What is required is 
that browsers become more consistent. A subdocument that is a PNG or 
JPEG can be seamless, so why not a subdocument that is a plain text 
file or an HTML document?

At the moment, browsers are in the process of improving SVG support. 
Some browser already handle <IMG SRC="foo.svg"> in the expected way, 
some still don't.

HTML support has to improve in the same way. There was a time that 
browsers didn't show anything at all when you embedded HTML. That has 
been fixed, fortunately, but browsers have to improve further. There is 
no reason why <IMG SRC="foo.html"> should create a 150 px high box, 
when <IMG SRC="foo.png"> is able to use the real size of the 
subdocument.



Bert

PS. Yes, I know, there could be a legacy problem there. Browsers have 
been mishandling compound documents for so long, that there are 
probably people who will be confused if the behavior changes. If that 
is indeed the case (but I'm not sure it is), we may have to use some 
keyword in CSS to toggle between the old and the new behavior, 
maybe 'height: auto' vs 'height: min-content', a keyword we'll be 
adding to CSS3 anyway.

-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Friday, 11 July 2008 14:57:20 GMT

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