Skip navigation
Currently Being Moderated

making a whole div clickable

May 24, 2012 1:18 PM

How do I make a whole div clickable?  I was referencing this site, but no luck.  Here is my code:

 

div:

<span id="link"><a href="google.com">This is an empty span</a></span>

 

css:

#link

{

...

}

 
Replies
  • Currently Being Moderated
    May 24, 2012 1:32 PM   in reply to future-architect

    Short ansewr, you can't.  An "a" tag encompassing a "div" tag is invalid code.  You can make it work like the menus work where the "a" tag is set to "display:block;" with padding and/or margins to make the block element act as a link rather than just the text.

     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2012 2:29 PM   in reply to future-architect

    This CSS Sprite Demo moves paragraph text off screen with text-indent: -9999em.  But the anchor is set to display:block with added height & width to give it some girth.  Span tags won't work for this.

    http://alt-web.com/DEMOS/CSS-Button-Sprite.shtml

     

     

    Nancy O.

    Alt-Web Design & Publishing

    Web | Graphics | Print | Media  Specialists 

    http://alt-web.com/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points