I'm trying to turn a div into a link. The code below works fine in firefox but in IE the mouse pointer doesn't react to the link. Is there a way around this? Thanks.
<html>
<head>
<style type="text/css">
.test{
width:100%;
height:100px;
background:#666666;
}
</style>
</head>
<body>
<a href="http://www.google.com">
<div class="test">
kjlkjlkjkljl
</div>
</a>
</body>
</html>
Why do you want to use a div
as a link?
Can't you just display your link as block?
a{
display:block;
}
Or use a span
instead of a div
.
As Welbog noted, the <a>
and <div>
elements should be reversed:
<div class="test">
<a href="http://www.google.com">
Lorem ipsum
</a>
</div>
Then in your style, you can make the <a>
tag expand to fill the entire div:
.test a {
display: block;
width: 100%;
height: 100%;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With