W3C home > Mailing lists > Public > www-style@w3.org > March 2006

Re: Resolving relative URLs in CSS

From: L. David Baron <dbaron@dbaron.org>
Date: Tue, 21 Mar 2006 19:24:21 -0800
To: www-style@w3.org
Message-ID: <20060322032421.GA31736@ridley.dbaron.org>
On Tuesday 2006-03-21 22:08 -0500, Vlad Alexander wrote:
> 
> Can someone please direct me to documentation on how users agents are
> supposed to resolve relative URLs in (external/embedded/inline) CSS?
> For example:
> 
> body { background: url("images/marble.png") }

> <head>
> <style>@import "format.css";</style>
> <base href="http://example.com/" />
> </head>

http://www.w3.org/TR/CSS21/syndata.html#uri says:
# In order to create modular style sheets that are not dependent on the
# absolute location of a resource, authors may use relative URIs.
# Relative URIs (as defined in [RFC3986]) are resolved to full URIs
# using a base URI. RFC 3986, section 5, defines the normative algorithm
# for this process. For CSS style sheets, the base URI is that of the
# style sheet, not that of the source document.

This means that for external stylesheets, the base URI is the same as
the stylesheet URI.

For style elements and attributes, the base URI is generally considered
to be the base URI on that node, although I don't think any
specifications define that.  Probably the CSS specification should
define that so that specifications such as HTML4 (which doesn't) and XML
Infoset / xml:base can define the base URI for an element.  See also
http://www.w3.org/TR/DOM-Level-3-Core/core.html#baseURIs-Considerations

-David

-- 
L. David Baron                                <URL: http://dbaron.org/ >
           Technical Lead, Layout & CSS, Mozilla Corporation

Received on Wednesday, 22 March 2006 03:24:41 GMT

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