Search code examples
htmlhref

HTML table in <a> tag


Is it possible to somehow place a whole HTML table in a href link?

Something like: (does not work in IE)

    <td class="order_confirm">
        <a href="ssss">
            <div>
                <table width="100%" border="0" cellspacing="6" cellpadding="0">
                  <tr>
                    <td><img src="design/img/icon_ok.png" width="22" height="22" alt="objednat" /></td>
                    <td width="0" class="order_confirm_order">OBJEDNAT</td>
                    <td width="100%" class="order_confirm_order_desc">Záväzne si objednávam uvedený tovar a súhlasím s platobnými,<br />
                      dodacími a obchodnými podmienkami prevádzkovateľa.</td>
                  </tr>
                </table>
            </div>
        </a>
    </td>

I am aware of the fact that this is not the best practice, however, I don't really see a workaround for this using a non-table layout... So a solution with a non-table layout would also be acceptable for me.


Solution

  • If you want your whole table as a link you can simulate it css and javascript.

    This example uses jQuery:

    <style>
        #big-link {
           cursor: pointer;
        }
    </style>
    
    <script>
    $(function() {
        $("#big-link").click(function() {
            window.location.href = "ssss";
        });
    });
    </script>
    <div id="big-link">
        <table>
             ...
        </table>
    </div>