SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hyperlink a row?

    Anyone know how to hyperlink a row? I want the whole row to be linked:
    Code:
    <a href='WebStatsYearsAndPeriods.php'>
     <tr>
      <td>$Year</td>
      <td>$Period</td>
     </tr>
     </a>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,253
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    row link

    Maybe
    HTML Code:
     <tr>
      <td><a href='WebStatsYearsAndPeriods.php'>$Year</a></td>
      <td><a href='WebStatsYearsAndPeriods.php'>$Period</a></td>
     </tr>

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Surely that does produce a similar effect, but without a bunch of Javascript, it doesn't produce the a:link, a:hover, a:visited effect. Instead it gives the impression that there are two individual links per row, whereas the idea is for there to be one link for the entire row.

    It's a puzzlement! I just don't get why it doesn't work.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,253
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    row link

    It must be something to do with block level elements as opposed to inline elements and what can be inside what. Have you tried
    HTML Code:
    <tr>
    <a href='WebStatsYearsAndPeriods.php'>
      <td>$Year</td>
      <td>$Period</td>
    </a>
     </tr>

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2004
    Location
    Temecula, CA
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just tried it. Same results -- nothing.

    I think you're right; it's got something to do with the block level status of the elements in question. I should stop wondering about it and read up on the subject. Wouldn't be surprised to find the W3C docs saying "you can't hyperlink a row!"

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,253
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    bock - inline

    It seems that table, tr, and td are block level elements (I don't see why td would be, but .... ) and a is an inline element. Inline elements can only have other inline elements in them, so table, tr, and td are out. http://www.ahuka.com/htmllevel1/blocklevel.html

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague
    tr, and td are block level elements (I don't see why td would be, but .... ) and ... &#91;i&#93;nline elements can only have other inline elements in them
    You answered your own question.
    If TDs were inline elements, you couldn't put anything but inline elements into them. Sometimes you may want to put an UL or OL, or even a DIV, inside a TD. Thus the TD must be a block-level element.

    @cweaver: there is no way to create a link out of an entire table row, using only HTML. You could do it with JavaScript, or if you're just after the :hover effect you can fake that with CSS in modern browsers. (IE won't play along, though.)
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •