在表格中建立图像链接

时间:2012-01-11 13:40:02

标签: javascript html hyperlink

有人知道如何通过此图片制作链接吗? 我是否必须将“背景”更改为“img src”? 或者我是否必须更改<a href>

<a href="index.html"><td  height="117" colspan="4" background="afbeeldingen/klein-2kolom_04.gif"></a>&nbsp;</td>

4 个答案:

答案 0 :(得分:1)

背景是背景。内容是内容。链接需要告知用户他们指向的位置,因此需要内容。表行不能作为子项具有锚点。表格细胞不能作为父母的锚点。 background属性已过时。

<td>
    <a href="index.html">
        <img src="afbeeldingen/klein-2kolom_04.gif" alt="DON'T FORGET THIS">
    </a>
</td>

答案 1 :(得分:0)

使用基于CSS的解决方案

<td  height="117" colspan="4" background="afbeeldingen/klein-2kolom_04.gif">
  <a href="index.html">&nbsp;</a>
</td>

应用以下css

td a {
  display:block;
}

答案 2 :(得分:0)

我测试并修改了Bangline解决方案:

<table>
    <tr>
        <td height="117" colspan="4" background="afbeeldingen/klein-2kolom_04.gif">
          <a href="index.html">&nbsp;</a>
        </td>
    </tr>
    <tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
</table>

td a {
  display:block;
  height: 117px;
}

http://jsfiddle.net/gSVhP/2/

答案 3 :(得分:-1)

一种方法是使用onClick事件:

<td height="117" colspan="4" background="afbeeldingen/klein-2kolom_04.gif" onclick="location.href='index.html';">&nbsp;</td>