I want to use an entire div as a link.. without the use of \"onclick\"
Is this possible with a simple href
?
Thanks
No, div
elements cannot have the href
attribute, nor will they act like links. You can use the following in HTML5:
<a href="#"><div></div></a>
However, not all current generation browsers (notably Firefox 3.6) supports this. The other alternative is to add a absolutely positioned a
element that has 100% width and height to the div
:
div a {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
This is valid HTML4, but it won't work on older versions of IE, of course. Otherwise should accomplish what you want. See: http://www.jsfiddle.net/uRh7j/
I do not think this is possible without the use of onclick event.You can use display:block;
for displaying the link as a div but nothing else.