Is there a way to make the entire area of a <div>
be a proper link?
Right now I'm doing this with javascript using the onclick
but this is not good since if I middle click it (on firefox) it doesn't open at all
Is there a way to make the entire area of a <div>
be a proper link?
Right now I'm doing this with javascript using the onclick
but this is not good since if I middle click it (on firefox) it doesn't open at all
What do you have inside the DIV? If it's just text and other inline elements, you can just do:
<div><a href="#" style="display: block;">....</a></div>
Your best choice would probably be to turn a link into a block element.
CSS:
#mylink { display: block; }
HTML:
<a href="#" id="mylink">Some Content</a>
You can make the link a block element or you can do:
<a href="#" style="display: block">
<div>content</div>
</a>
Edit: this fails w3c validation even tho you defined the anchor tag to be "block". I don't know if this is actually against the spec (block elements inside of inline elements) or if the W3C validator simply ignores the style tag and parses it as if it were still an inline element. Does anyone know which the case is? Either way making the anchor tag a block element is the simplest solution <a style="display: block"></a>