Ever had a need to make a div clickable? I have. I was searching for a way to do this very thing and came across a couple of different methods to acomplish it.
Well you might have a “banner” div that contains an image in the background and you want to make this area link back to the main page of your site.
<div onclick=”location.href=’http://www.example.com’;” style=”cursor:pointer;”></div>
<div id=”header” onclick=”location.href=”http://www.example.com”;” style=”cursor:pointer;”>
The other way… which may or may not work in some browsers is to add a set of a – /a.
It is my understanding that this will only work if the “div” you are trying to make clickable is nested within another “div” because the “a” link cannot be a block level element. It must be inside a block level element.
So, with that in mind you would need to do something like this:
<a href=”index.htm” title=”Click Here to get back to the main paige”><div id=”banner”> </div></a>
There is another method that I was reading about adding a style to the “a” tag in your css.. I’ll post more on that later.
© 2006 – 2009, Robert Owen. All rights reserved.