views:

58

answers:

2

I have a href link:

/agenda/#Testevent

Which in IE it goes to the corresponding <h4> element but in Firefox it doesn't work.

I have used this named anchor:

<h4 name="#Testevent" id="#Testevent">

Any suggestions?

+7  A: 

Drop the '#'

name="Testevent"

remi bourgarel
Actually, it is the `id` attribute that needs to drop the `#`.
Daniel Vassallo
If you want to link to an anchor with the name #foo you have to use page.html#%23foo, which is nasty and doesn't make sense. The name is the name. The # is just a character in URIs that indicates a fragment id will follow.
David Dorward
@Daniel Vassalo : no i'm right http://www.w3schools.com/tags/att_a_name.asp
remi bourgarel
@remi: Maybe you didn't notice, but the OP is using an `<h4>` tag not an `<a>`.
Daniel Vassallo
@Daniel : I'm sorry ! @alex : You can't do an anchor with a hn tag, you have to use an anchor tag : <a>, even if it works under some browser, please respect standard.
remi bourgarel
@remi: Actually the HTML 4.01 standard (http://www.w3.org/TR/html401/struct/links.html#h-12.1.1) does allow you to use any element as an anchor, but it has to be identified with the `id` attribute instead of with the `name`. Therefore the OP can use `<h4 id="Testevent"></h4>`. I tested this with the latest versions of Firefox, Chrome and IE, and it works fine.
Daniel Vassallo
+4  A: 

You can either do this:

<h4><a name="Testevent">Title</a></h4>

Or else you can also do this:

<h4 id="Testevent">Title</h4>

"Destination anchors in HTML documents may be specified either by the A element (naming it with the name attribute), or by any other element (naming with the id attribute)."

Source: w3.org: Links in HTML documents

Daniel Vassallo