Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4326940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:28:08+00:00 2026-05-21T09:28:08+00:00

I have a <table> where each <td> holds only an anchor. I’d like users

  • 0

I have a <table> where each <td> holds only an anchor. I’d like users to be able to click anywhere in the cell to visit that reference rather than only on the anchor text itself. I imagine there must be a bit of jQuery to do this easily. Can anyone help?

Edit: To complicate things, my td‘s have some top and bottom padding. A display: block; rule doesn’t seem to work in this case. I’ve edited the example:

CSS:

table#mainmenu td {
    padding: 9px 8px 5px;
    border: none;
    border-bottom: 1px solid #ccc;
    border-left: 1px dotted; 
    text-align: left;
}

Example:

<table>
<tr>
  <td><a href="foo.html">Foo</a></td>
  <td><a href="bar.html">Bar</a></td>
</tr>
<tr>
  <td><a href="foobar.html">FooBar</a></td>
  <td><a href="barfoo.html">BarFoo</a></td>
</tr>
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:28:08+00:00Added an answer on May 21, 2026 at 9:28 am

    Just make the A tag display: block.

    table td a {
      display: block;
    }
    

    http://jsfiddle.net/userdude/6VZ8t/

    Or, if you insist on jQuery:

    $('table td a').css('display','block');
    

    http://jsfiddle.net/userdude/a2EAz/

    EDIT

    Since I wasn’t able to find a CSS-only way to select a parent TD of a child A, this solution does use jQuery:

    function doTablePadding() {
        $td = $('table td');
        $td.has('a').css('padding','0');
        padding = $td.not(':has(a)').css('padding-top') + " ";
        padding += $td.not(':has(a)').css('padding-right') + " ";
        padding += $td.not(':has(a)').css('padding-bottom') + " ";
        padding += $td.not(':has(a)').css('padding-left') + " ";
        $td.children('a').css('padding',padding);
    }
    doTablePadding();
    $('table tbody').append("<tr><td>Stuff</td><td><p>Other stuff</p></td></tr>");
    $('table tbody').append('<tr><td><a href="foo.html">Foo</a></td><td><a href="bar.html">Bar</a></td></tr>');
    doTablePadding();
    

    http://jsfiddle.net/userdude/Mekjg/1

    Note that this is running from $(document).ready();.

    EDIT 2

    As mu is too short notes, negative margins should work (and no jQuery):

    td {
        padding: 5px;
        background: #0ff;
        border: 1px solid black;
    }
    td a {
        display: block;
        margin: -5px;
        padding: 5px;
        background: #f0f;
    }
    

    http://jsfiddle.net/ambiguous/seqpp/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table that holds parent and child records much like a
I have a table with each cell containing a label and a text field.
I have a table that stores all the volunteers, and each volunteer will be
I have a table that has about 1/2 million records in it. Each month
Question for YUI experts... I have a table and I've made each cell of
I have a monthly table (only holds rows with first day of month, and
I have 2 tables: ATTACHEMENTS and EMAILS (analogic example). ATTACHEMENTS table holds for each
I have a MYSQL table that holds events information. I need a mechanism that
I happen to have a database with a table that holds all possible combination
I'm looking for a best practice solution.... I have table that holds products called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.