Tareq Tareq - 1 month ago 10
CSS Question

How can I expand an <a> tag into a <div> Tag?

I have the following div:

<div style="height: 200px">
<a href="#">Click to View</a>
</div>


I want to click anywhere of the div tag and want to activate the tag means in short I want to click on the Div to navigate the link. How can I do that?

Thanks in advance for helping me.

UPDATE:

Sorry friends, I have to update my question...


  1. I can not define the exact height of my
    <div>

  2. I have to use 100% for height for
    <a>



My revised code is like that:

<div>
abc<br><br>
<a href="#">Click to View</a>
</div>


Please help me...

Answer

Make a Javascript function which calls the Link and attach it on the OnClick event of the DIV Element.

Or try something like:

<div id="Idhere" onclick="window.location = 'Link here'">
<a href="leave this blank">text here</a>
</div>