W3C home > Mailing lists > Public > public-html@w3.org > December 2010

Re: Hoisting <base> into <head>

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 8 Dec 2010 07:47:26 +0000 (UTC)
To: "L. David Baron" <dbaron@dbaron.org>
cc: Henri Sivonen <hsivonen@iki.fi>, public-html <public-html@w3.org>
Message-ID: <Pine.LNX.4.64.1012080739150.27980@ps20323.dreamhostps.com>
On Tue, 7 Dec 2010, L. David Baron wrote:
> 
> HTML5 says though its definition of document base url in
> http://dev.w3.org/html5/spec/urls.html#document-base-url that the
> base element applies to all of the document, including (through lack
> of anything saying otherwise, as far as I can tell) what is before
> the base element.  (This recently changed to include all base
> elements rather than only those in the head, it appears.)

That's accurate but incomplete. What is missing from this description is 
the account of when URLs are resolved. This is also defined in the HTML 
spec now, and differs based on the exact context of the URL. With a very 
few select exceptions, changing the document base URL does not cause 
relative URLs in the document to be immediately reresolved, which can give 
the appearance that the document base URL affects elements before and 
after the <base> in different ways.


> Consider, for example, this test that I just wrote:
>   http://dbaron.org/css/test/2010/base/test.html
> It contains three style elements interleaved with two base elements
> (style 1, base 1, style 2, base 2, style 3).

In the case of <style> elements, the HTML specification says:

# All URLs found by the styling language's processor must be resolved, 
# relative to the element (or as defined by the styling language), when 
# the processor is invoked.

Currently the HTML specification does not specify when the CSS processor 
is to be invoked for inline CSS fragments in <style> elements, as it 
depends on the processing of alternative style sheet sets, which is 
to be defined in the CSSOM specification. I don't believe CSSOM yet 
specifies exactly when a style sheet is to be processed.


> In Firefox 3.6, Chromium from late June, and Opera 11 beta, base 1
> applies to style 2, and base 2 applies to style 3.

Applying base 2 to anything is non-conforming per the contemporary HTML 
spec, but is historically how <base> elements have been handled, so it is 
unsurprising that some browsers (still) do this.


> In IE8 and Firefox trunk, base 1 applies to both style 2 and style 3, 
> but not style 1.

This is consistent with the specification if one assumes that <style> 
elements are processed by the CSS processor immediately upon the <style> 
element's end tag being parsed.


> HTML5 says (I think) that base 1 should apply to all three style 
> elements, which doesn't match any of the browsers I tested.

Hopefully the above explains the intent of the specification.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 8 December 2010 07:47:56 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:16:07 UTC