Div as a link?

Discussion in 'CSS' started by le007, Apr 4, 2009.

  1. #1
    Hi all - I need a div around 200px x 200px to be an actual link - is this possible?
    Thanks
     
    le007, Apr 4, 2009 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Make it an anchor instead of a div, set it to:

    display:block;
    position:relative;
    width:200px;
    height:200px;

    position:relative makes the whole thing clickable in the allegedly standards compliant browsers, and the width/height trips haslayout so the entire area should also be clickable in IE.

    You could also try adding 'onclick' to the div, but that's an accessability /FAIL/ so I'd not take that approach.
     
    deathshadow, Apr 4, 2009 IP
  3. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    An anchor as in <a href="whatever" class="whatever">? thanks for reply
     
    le007, Apr 7, 2009 IP