I want to use an entire div as a link.. without the use of \"onclick\"
Is this possible with a simple href?
Thanks
Wrap an anchor around it.
<a href="#"><div></div></a>
why not you use javascript framework such as jquery, let the div has no onclick event but declare an event in jquery, such this:
<script>
$(function(){
$(".click").click(function{ alert('clicked!'); });
});
</script>
<div class="click"></div>
just my 2 cents. thanks.
You can accomplish this by creating a small transparent PNG (say, 10px * 10px) and using CSS to set the width and height of the PNG to 100%. Then you can wrap the img tag with your a href tag.
Here's the HTML:
<div id="YourHeader">
<a href="http://example.com"><img src="/path/to/header10x10.png" /></a>
</div>
Here's the CSS:
#YourHeader img {
width: 100%;
height: 100%;
}
This is especially handy if #YourHeader is an empty div whose only purpose is to display a header image via its background-image attribute.
you can't. but you could use an <a> with style="display:block", wich should behave exactly like a <div>, to replace your <div>
Per the HTML spec (HTML 4.01, Draft 5 and XHTML 1,1.1) an anchor tag <a> cannot enclose a <div> tag.
simple answer is no, you can use onclick with css cursor:pointer to get the same functionality, though.