Alex Rivera | Logout

How do you make a div tag into a link

Asked 2009-11-06T02:40:42.847
20

How do you make a div tag into a link. I would like my entire div to be clickable.

Edit
Report

2 Answers

12

If you have to set your anchor tag inside the div, you can also use CSS to set the anchor to fill the div via display:block.

As such:

<div style="height: 80px"><a href="#" style="display: block">Text</a></div>

Now when the user floats their cursor in that div the anchor tag will fill the div.

answered 2009-11-06T03:08:59.803
7

DON'T DO IT.

  • If you want a link, wrap the content in the proper <A>NCHOR</a>.
  • If you want to turn the <DIV> into a link, use "Javascript" to wrap the <DIV> inside an <A>NCHOR</A>
  • If you want to perform some action when clicking the <DIV> use the onclick event handler... and don't call it a "link".
answered 2009-11-06T02:50:27.330

Your Answer