How to make a whole 'div' clickable in html and css without JavaScript?

Andy Lobel picture Andy Lobel · Nov 17, 2011 · Viewed 439.6k times · Source

I want to make it so that a whole div is clickable and links to another page when clicked without JavaScript and with valid code/markup.

If I have this which is what I want the result to do -

<a href="#">
<div>This is a link</div>
</a>

The W3C validator says that block elements shouldn't be placed inside an inline element. Is there a better way to do this?

Answer

Mario picture Mario · Jan 19, 2012

It is possible to make a link fill the entire div which gives the appearance of making the div clickable.

CSS: