aklein
aklein

Reputation: 81

Anchor inside <h1> tag

I have a little problem, maybe a stupid one, but a problem:

On my page I have a anchor-menue. In the past this worked very well, but now it suddenly stopped working. Interesting fact is that only anchors inside elements stopped working.

For example:

<h1><a name="anchor1" id="anchor1"></a>Nice little headline goes here</h1>

This one dosn't work, but this one works:

<a name="anchor2" id="anchor2"></a>

The website with the problem is: www.kleinbild.org

The anchor in code-line 126 on index-page with the ID "pagetop" is working pretty well for example, but the one in line 155 with the ID "anker1" don't.

I've now tried to put some Text inside the anchor like Luke suggested me, but the result is the same. Little example:

<h1><a name="anchor1" id="anchor1">Nice little headline goes here</a></h1>

Now the question of all questions is: why? I would be very glad if someone could give me an answere for this little problem. Thanks a lot!

Upvotes: 4

Views: 3845

Answers (2)

Avinash Jain
Avinash Jain

Reputation: 7606

You have two issues with your HTML:

  • First text should come inside anchor.
  • Second you should use href attribute inside anchor to make it work.

Your html should look like following

<h1>
    <a name="anchor1" id="anchor1" href="/redirectToSomePlace">
        Nice little headline goes here
     </a>
</h1>

Upvotes: 2

Luke
Luke

Reputation: 5602

I suspect one of the possible issues is that your link inside your h1 tag has no text inside it.

You have this:

<h1><a name="anchor1" id="anchor1"></a>Nice little headline goes here</h1>

But don't you really want this?

<h1><a name="anchor1" id="anchor1">Nice little headline goes here</a></h1>

Upvotes: 5

Related Questions