Page 1 of 1

named anchors and the base tag

Posted: Fri Apr 27, 2007 1:28 pm
by Luke
I've got a page with a base tag (has to be there) and named anchors. I want to be able to just use <a href="#anchorname">This is the name</a> but when I do that, it takes me to "basehref#anchorname" when I want it to go to "currenturl#anchorname". Is this just not possible with a base tag? Do I have to know what page I'm on to do this?

Also... if I put in a url like this:

Code: Select all

<a href="/article/why-people-smell-bad#section">Section</a>
If I am already on /article/why-people-smell-bad, will it reload the page? I can't really tell.

EDIT: Another question

How come this works? I mean, how come this anchor leads to this section of the page?

Code: Select all

<a href="#section">Anchor link</a>

<div id="section"></div>
I thought a named anchor was required for that:

Code: Select all

<a href="#section">Anchor link</a>

<a name="section"></a>
d11wtq | Fixed your highlighting... "html" needs to be lowercase

Re: named anchors and the base tag

Posted: Fri Apr 27, 2007 6:18 pm
by Weirdan
The Ninja Space Goat wrote: EDIT: Another question

How come this works? I mean, how come this anchor leads to this section of the page?

Code: Select all

<a href="#section">Anchor link</a>

<div id="section"></div>
I thought a named anchor was required for that:

Code: Select all

<a href="#section">Anchor link</a>

<a name="section"></a>
HTML 4.01 wrote: The id attribute has several roles in HTML:
  • As a style sheet selector.
  • As a target anchor for hypertext links.
  • As a means to reference a particular element from a script.
  • As the name of a declared OBJECT element.
  • For general purpose processing by user agents (e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.).