Parsing relative URLs

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

While parsing relative URL segments "../" to hierarchical segments of
the absolute URL , I notice that the <a> tag and the <link> tag do
this differently. Take the following absolute and relative URLs:

absolute URL:
relative URL: ../../b/c.css

The <a> tag resolves this to:

However the <link> tag resolves this to:

It appears that all other forms of resolving URLs are equal between
both tags however, I have been trying to find the RFC specification on
this but have had no luck. This document
does not contain any information regarding the <link> tag.

Is anyone here familiar with this or know where I could obtain more



Re: Parsing relative URLs

In our last episode,
lovely and talented broadcast on alt.html:

Quoted text here. Click to load it

But this is nonsense.  It is looking for the parent of the root,
but of course there cannot be one.

Quoted text here. Click to load it

In other words, some browser or another, presented with an absurdity, has
inconsistent error handling.  Well, obviously, other than writing to the
authors of the browser about that, the solution would be not to write
relative URLs that are absurd.

Quoted text here. Click to load it

I don't think you will find many specs that deal with error recovery.  There
are so many possible errors that the point of defining the right way would
be lost in all the stuff about what to do when people do things the wrong

Quoted text here. Click to load it

Lars Eighner <
                         Countdown: 232 days to go.

Re: Parsing relative URLs wrote:
Quoted text here. Click to load it

Not in my test.

Quoted text here. Click to load it

File /a/b/c.css:

body { color: red; }

File /b/c.css:

body { color: green; }

File /a/b/x.html:

" ">
    <title>Relative URLs: Link vs. A</title>
    <link rel="stylesheet" type="text/css" href="../../b/c.css">

    <p>If the LINK tag resolves the relative URL
    to http://localhost/b/c.css, this will be green.</p>
    <p>If it resolves it to http://localhost/a/b/c.css,
    this will be red.</p>
    <p><a href="../../b/c.css">Click here</a></p>

In both Internet Explorer and Firefox, the page's text appears in green,
and the link leads to the file that reads

body { color: green; }

In other words, both the LINK and the A tags point--correctly--to
/b/c.css. Therefore, I think you made a mistake somewhere in your

Site Timeline