• Horn Player – Computer Dude – Gig Pig …
  • Home
  • About
  • Blog
  • Services
  • Contact
  • Webmail
  • Terms

Robert A. Owen - Musician - Technology Leader

Music, Technology, Rants and Funnies - Randomness at its best!

  • Blog
  • Internet
    • IIS 6
    • IIS 7.5
    • Javascript
    • Web Design
      • WordPress
      • Coldfusion
  • Support
    • MicroSoft
      • Powershell
      • Surface
      • Windows10
      • Zune
    • PC-Care
    • Software
    • Virus
      • Email Scam
    • Vista Quest
    • Windows 7
  • Pictures
    • Instagram
  • Music
  • Friday Funnies
  • General
    • CoWorking
    • Gadgets
    • Politico
    • Random – TidBit
    • Rant
    • Review
    • Site of the Week
    • Useless
    • Xbox
      • Games
You are here: Home / Internet / Web Design / Making a DIV Clickable

Making a DIV Clickable

November 17, 2006 By Robert Owen

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.
We can use javascript or apply the a – /a tags.

It’s fairly easy to make any div clickable by adding a bit of JavaScript to the tag. You might be asking … WHY?!

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.

Here’s how it can be done with some javascript:
<code>
<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;”>
</div>
</code>

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:

<code>
<a href=”index.htm” title=”Click Here to get back to the main paige”><div id=”banner”>&nbsp;</div></a>
</code>

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.

Related posts:

Default ThumbnailCFX_PFPro_Java Download – Finally Default ThumbnailCSS – Long URL Default ThumbnailHugged your Developer today? Default ThumbnailWindows 2003 Server does not stream FLV videos

Filed Under: Web Design Tagged With: Amp Nbsp, Banner, Css, Div Id, Javascript, Javascript Code, Level Element, Lt, Nbsp, Paige, Pointer, Style Cursor, Tag

Robert Owen A Horn Player turned salesman, turned Computer Consultant & Horn Player, Turn Network Engineer & Horn Player, Now Technology leader & Musician.... Well, How about a Horn player who does a lot of other stuff? More about me. FacebookInstagramLinkedInTwitter

To Stay up-to-date on all of my crazy Ramblings, enter your e-mail address below.

You'll be amazed!

Recent Posts…

  • What If? – Gig Edition
  • Feedback – two way street
  • Snow-pocalypse… and Cold
  • Snow-pocalypse 2025 – part 6
  • Snow-pocalypse 2025 – part 5

Recent Comments

  • David Gray on Create a Shortcut to open in your Alternate BrowserTwelve years on, this tip remains useful. Though I…
  • Sue K on Use the Snipping Tool to Capture MenusThanks you so much! I could never figure out how t…
  • aa on Increase IIS File Upload LimitsSuperb Robert..after wasting 2 days..this is perfe…
  • León on Windows 7 error 86Funciono para Windows 7 , también descubrí que la…
  • Nicole Larkin on Use the Snipping Tool to Capture MenusNine years later and your post is still helpful. T…

[footer_backtotop]
Content Copyright © 2025 OWEN CONSULTING · All Rights Reserved · Log in