Hamed Parvini
Hamed Parvini

Reputation: 21

How to make a div into a Hyperlink?

I have problem in Visual Studio 2008 (ASP.net with C#).

I have div#apDiv13, now I want to make my div a hyperlink.

I set my div's background and now I want it to be a hyperlink on mouse over or go to some address in web on-click.

Screenshot

Upvotes: 1

Views: 1013

Answers (2)

nu everest
nu everest

Reputation: 10269

Simple way:

<a href="http://stackoverflow.com/">
    <div>Contents of your div</div>
</a>

Upvotes: 0

Stan
Stan

Reputation: 26511

This is very bad idea but technically it's possible. What you need to do is display link as a block and set its size to 100% vertically and horizontally so it fills the container div.

Example (http://jsfiddle.net/snLwg/)

div {
    background: red;
    width: 300px;
    height: 300px;
}

div a {
    display: block;
    height: 100%;
    width: 100%;
}

Upvotes: 3

Related Questions