We help IT Professionals succeed at work.

can I make an entire DIV element clickable with a <a> link?

Brad Bansner
Brad Bansner asked
on
372 Views
Last Modified: 2012-05-11
Is there some way to do something similar to this:

<a href="#"><div class="clickbox">content here</div></a>

...and have the entire DIV be clickable? So not just the text "content here" but the whole box? Like if I set a width: 300px height 300px anywhere within that would link? Thank you!
Comment
Watch Question

Senior Software Engineer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Greg AlexanderLead Developer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
Brad BansnerWeb Developer

Author

Commented:
Hmm, I must be doing something wrong on this page, then:

http://www.dbiservices.com/new/deangelobrothersinc/alenza1.asp

#caption1 {
            border: 1px solid #000000;
            position: absolute;
            width: 200px;
            height: 20px;
            top: 357px;
            left: 282px;
            padding: 80px 0px 0px 0px;
      }

<a href="http://www.dbiservices.com"><div id="caption1"><p class="nobr">Click for product labels and MSDS</p></div></a>

Any idea why mine aren't clickable at all?
Greg AlexanderLead Developer

Commented:
Try with an onclick
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Brad BansnerWeb Developer

Author

Commented:
Ah, I found the problem. They were positioned absolutely. I changed z-index:2 and now they work. Thanks for the input!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.