W3C home > Mailing lists > Public > www-html@w3.org > December 2001

Re: anchors

From: Masayasu Ishikawa <mimasa@w3.org>
Date: Mon, 03 Dec 2001 13:08:32 +0900 (JST)
Message-Id: <20011203.130832.41626808.mimasa@w3.org>
To: www-html@w3.org
"Hoyt, Phil" <Phil.Hoyt@globeinteractive.com> wrote:

> I think it's common practice to link using href="#name" to an anchor within
> the same document. I've been unable, though, to find a way either in the
> real world or in the html spec to use a similar syntax to link to an anchor
> within the same document as the link when <base href="http://www.url.com">
> is being used. Instead, such a link refers to an anchor on the base
> document.

Actually such a behavoir is wrong, RFC 2396, "4.2. Same-document
References" says:

   A URI reference that does not contain a URI is a reference to the
   current document.  In other words, an empty URI reference within a
   document is interpreted as a reference to the start of that document,
   and a reference containing only a fragment identifier is a reference
   to the identified fragment of that document.  Traversal of such a
   reference should not result in an additional retrieval action.
		<snip/>

And "5.2. Resolving Relative References to Absolute Form" further says:

   For each URI reference, the following steps are performed in order:

   1) The URI reference is parsed into the potential four components and
      fragment identifier, as described in Section 4.3.

   2) If the path component is empty and the scheme, authority, and
      query components are undefined, then it is a reference to the
      current document and we are done.  Otherwise, the reference URI's
      query and fragment components are defined as found (or not found)
      within the URI reference and not inherited from the base URI.

So a fragment identifier should be interpreted as a reference within
the current document, regardless of the base URI.  Unfortunately,
as you noticed, many user agents do it wrong.

[RFC 2396] http://www.rfc-editor.org/rfc/rfc2396.txt

Regards,
-- 
Masayasu Ishikawa / mimasa@w3.org
W3C - World Wide Web Consortium
Received on Sunday, 2 December 2001 23:08:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:50 GMT