tables and anchors

Discussion in 'HTML' started by eliza.block@gmail.com, Dec 20, 2007.

  1. Guest

    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
     
    , Dec 20, 2007
    #1
    1. Advertising

  2. dorayme Guest

    In article
    <>
    ,
    wrote:

    > 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...

    --
    dorayme
     
    dorayme, Dec 20, 2007
    #2
    1. Advertising

  3. rf Guest

    <> wrote in message
    news:...
    > 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.

    The error correction I have seen is to put the offending <a> at the top of
    the table.

    > 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 <td> in a <table>. They must be inside a <tr>.

    > Is there a neat solution that I'm missing?


    Apply the id to an existing row:
    <tr id="S"><td ...


    > Thanks!
    > Eliza
     
    rf, Dec 20, 2007
    #3
  4. wrote:
    > 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.
     
    Harlan Messinger, Dec 20, 2007
    #4
  5. Scripsit :

    > 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.


    Anything between rows (except <tbody> tags, which is irrelevant here) is
    invalid markup.

    > 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">.)

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Dec 22, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris M

    Bookmark Anchors and VB.NET

    Chris M, Oct 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    839
  2. Lars Netzel

    What about Anchors (#) and ASP.NET?

    Lars Netzel, Jul 26, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    509
    Justin Beckwith
    Jul 27, 2004
  3. JohnZing

    redirect, parameters and anchors

    JohnZing, Aug 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    527
    David Jessee
    Aug 23, 2004
  4. Rowan Malin
    Replies:
    10
    Views:
    1,073
    Foofy (formerly known as Spaghetti)
    May 14, 2004
  5. Hooligan

    Tables and anchors

    Hooligan, Nov 23, 2004, in forum: Javascript
    Replies:
    4
    Views:
    90
Loading...

Share This Page