Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to make a whole div clickable?

I remember Nick showed us in a tutorial on how to accomplish this, but I can't seem to find it. From what I recall, it doesn't require JavaScript.

What I have is a div with a link inside, but I want to make the whole div clickable like a button.

Show us what you've got so far by creating a demo using codepen

This is what I have

http://cdpn.io/heyrm

1 Answer

You should be able to just wrap the div in an anchor tag "<a>" and it will turn the div into a link

Also make sure that anchor tage is display: block, width: 100%,