javascript - Making an image link in a table - Stack Overflow

Does somebody know how to make a link form this image?Do I have to change "background" to &q

Does somebody know how to make a link form this image? Do I have to change "background" to "img src"? Or do I have to change the <a href>?

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

Does somebody know how to make a link form this image? Do I have to change "background" to "img src"? Or do I have to change the <a href>?

<a href="index.html"><td  height="117" colspan="4" background="afbeeldingen/klein-2kolom_04.gif"></a>&nbsp;</td>
Share Improve this question asked Jan 11, 2012 at 13:40 kimkim 831 gold badge3 silver badges9 bronze badges 5
  • What have you tried? In the time you have taken to ask this question, you could have tested several different ways. – Oded Commented Jan 11, 2012 at 13:41
  • I tried different things with <a href>, it is Javascript, in HTML it will be work. I'm working with tables, so maybe that's the issue? – kim Commented Jan 11, 2012 at 13:43
  • Why did you end the <a> tag before you ended the <td> tag? – itdoesntwork Commented Jan 11, 2012 at 13:43
  • Why are you wrapping an anchor around a td? What exactly do you want to do here? Can you explain, in your questions, in clear terms, what you are trying to achieve? – Oded Commented Jan 11, 2012 at 13:44
  • I find out that it has nothing to do with the code. The image is integrated into another image, so I can not edit it. It is not my code and not my design, so one big puzzle. Thank you all for your help, but it's better to give up this piece of S***! – kim Commented Jan 11, 2012 at 14:12
Add a ment  | 

4 Answers 4

Reset to default 2

Backgrounds are backgrounds. Content is content. Links need to inform users about where they point and so require content. Table rows cannot have anchors as children. Table cells cannot have anchors as parents. The background attribute is obsolete.

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

One way would be to use the onClick event:

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

To use a css based solution

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

Apply the following css

td a {
  display:block;
}

I tested and modified Bangline solution:

<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/gSVhP/2/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745117208a4612199.html

相关推荐

  • javascript - Making an image link in a table - Stack Overflow

    Does somebody know how to make a link form this image?Do I have to change "background" to &q

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信