tables and anchors

E

eliza.block

Does anyone know an elegant way to put anchors into a table? I have a
large table with names, addresses, phone numbers for 100+ people, and
links at the top to letters of the alphabet. I'd like to be able to
put anchors within the table so that clicking on, say, "S" jumps to
the names ending in S. But putting a line like <a id="S"></a> into the
table between rows doesn't work. (It always jumps to the top of the
table.) Same result for <div id="S"></div>.

I discovered that <td id="S"></td> generates the right behavior; the
problem is that it leaves an ugly space between rows in the table.

Is there a neat solution that I'm missing?

Thanks!
Eliza
 
D

dorayme

<[email protected]>
,
Does anyone know an elegant way to put anchors into a table? I have a
large table with names, addresses, phone numbers for 100+ people, and
links at the top to letters of the alphabet. I'd like to be able to
put anchors within the table so that clicking on, say, "S" jumps to
the names ending in S. But putting a line like <a id="S"></a> into the
table between rows doesn't work. (It always jumps to the top of the
table.) Same result for <div id="S"></div>.

I discovered that <td id="S"></td> generates the right behavior; the
problem is that it leaves an ugly space between rows in the table.

Is there a neat solution that I'm missing?

You are also missing a url to show us so that we can tweak it for
you...
 
R

rf

Does anyone know an elegant way to put anchors into a table? I have a
large table with names, addresses, phone numbers for 100+ people, and
links at the top to letters of the alphabet. I'd like to be able to
put anchors within the table so that clicking on, say, "S" jumps to
the names ending in S. But putting a line like <a id="S"></a> into the
table between rows doesn't work. (It always jumps to the top of the
table.) Same result for <div id="S"></div>.

That's because you cannot have an <a> between rows in a <table>. In fact the
only thing you can have in a <table> is <tr>'s, or perhaps a <tbody> etc.

I discovered that <td id="S"></td> generates the right behavior; the
problem is that it leaves an ugly space between rows in the table.

You also cannot put a said:
Is there a neat solution that I'm missing?

Apply the id to an existing row:
 
H

Harlan Messinger

Does anyone know an elegant way to put anchors into a table? I have a
large table with names, addresses, phone numbers for 100+ people, and
links at the top to letters of the alphabet. I'd like to be able to
put anchors within the table so that clicking on, say, "S" jumps to
the names ending in S. But putting a line like <a id="S"></a> into the
table between rows doesn't work. (It always jumps to the top of the
table.) Same result for <div id="S"></div>.

I discovered that <td id="S"></td> generates the right behavior; the
problem is that it leaves an ugly space between rows in the table.

Is there a neat solution that I'm missing?

Yes, there isn't any reason to put the anchor in its own cell at all.
Put it directly in front of the first name that begins with S, within
the cell that contains it.
 
J

Jukka K. Korpela

Scripsit (e-mail address removed):
I'd like to be able to
put anchors within the table so that clicking on, say, "S" jumps to
the names ending in S. But putting a line like <a id="S"></a> into the
table between rows doesn't work.

I discovered that <td id="S"></td> generates the right behavior; the
problem is that it leaves an ugly space between rows in the table.

You shouldn't use dummy (empty) cells. Instead, put the id="S" attribute
into the <td> tag of the first cell in a row. (You could also use <tr
id="S">.)
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top