internal webpage links

D

dorayme

Anyone know this please? Is the construction

<a id="something"></a>

without anything between opening and closing
tags kosher? That is, put at the place one wants the referring
link to target. It seems to work ok in strict 4.01, but I have
in the past avoided it. But if it is acceptable practice with no
bad cons, it is mighty convenient (able to be simply cut and
paste into the page just above the bit you want the link to go
to).

Or should one have to wrap it around something like a bit of
text or an image:

<h1><a id="something">This should appear</a></h1>

dorayme
 
M

Mark Parnell

Previously in alt.html said:
<a id="something"></a>

without anything between opening and closing
tags kosher?

It's permitted by the specs, but I would recommend against it. The specs
note:

"Note. User agents should be able to find anchors created by empty A
elements, but some fail to do so."

While this is probably not relevant now (the specs *are* nearly 6 years
old), any browser that can find an anchor by id can match the id on any
other element too.

Also, if you have any CSS rules like a {...}, they will apply to your
empty anchors, as well as any actual links. You can avoid that by making
sure you use a:link, but it's easier to avoid empty anchors.
<h1><a id="something">This should appear</a></h1>

An id can go on any element, so the <a> is superfluous.

<h1 id="something">This should appear</h1>
 
D

dorayme

From: Mark Parnell said:
It's permitted by the specs, but I would recommend against it. The specs
note:

"Note. User agents should be able to find anchors created by empty A
elements, but some fail to do so."

While this is probably not relevant now (the specs *are* nearly 6 years
old), any browser that can find an anchor by id can match the id on any
other element too.

Also, if you have any CSS rules like a {...}, they will apply to your
empty anchors, as well as any actual links. You can avoid that by making
sure you use a:link, but it's easier to avoid empty anchors.


An id can go on any element, so the <a> is superfluous.

<h1 id="something">This should appear</h1>


Thank you. I greatly appreciate this advice, especially the last bit about
<a> being superfluous when using ids This will make life simpler.

dorayme
 
E

Ed Jay

Toby Inkster said:
Use:
<h1 id="something">This should appear</h1>

Use <a name="foo"></a> at the location you want to link to on page
xxx.html. Then point to it using <a href="xxx.html#foo">.

Ed Jay (remove M to respond)
 
D

dingbat

Ed said:
Use <a name="foo"></a> at the location you want to link to

No, don't do that (it's wrong for at least two, arguably three reasons)

Just search this newsgroup or c.i.w.a.h instead.
 
B

Blinky the Shark

Ed said:
Use <a name="foo"></a> at the location you want to link to on page
xxx.html. Then point to it using <a href="xxx.html#foo">.

What's the advantage to doing that over naming the actual element you
wish the link to take the user to?
 
E

Ed Jay

Blinky the Shark said:
What's the advantage to doing that over naming the actual element you
wish the link to take the user to?

Case of 'that's the way I've always done it.' No other good reason.

Ed Jay (remove M to respond)
 
D

dorayme

From: Toby Inkster said:
Use:
<h1 id="something">This should appear</h1>

Yes, thank you, as Mark Parnell suggested too. I am already
changing every bit of appropriate mark-up on my sites (as I come
across them in good time) to implement this. Nice and simple. I
have always had a vague uncomfortable feeling using the anchor
tags and even name="" even though all worked fine...

dorayme
 
J

jake

dorayme said:
Anyone know this please? Is the construction

<a id="something"></a>

without anything between opening and closing
tags kosher? That is, put at the place one wants the referring
link to target. It seems to work ok in strict 4.01, but I have
in the past avoided it. But if it is acceptable practice with no
bad cons, it is mighty convenient (able to be simply cut and
paste into the page just above the bit you want the link to go
to).

Or should one have to wrap it around something like a bit of
text or an image:

<h1><a id="something">This should appear</a></h1>

dorayme

I would tend to use :
<h1><a name="something" id="something">INTRODUCTION.</a></h1>

( name="something" keeps it compatible with older browsers which don't
support 'id')

Or occasionally:

<div style="width:100%;">
<h1><a name="something" id="something">INTRODUCTION.</a></h1>
</div>

On the occasions when the page has to work 'keyboard-only' on IE and
behave like other browsers when tabbing from link-to-link.

regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top