Jump to content


Clicking Divs


6 replies to this topic

#1 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 03 November 2007 - 11:06 AM

Is there a way to make a div a link? I have some information in a div and i dont want then to have to click the image next to the text to have to go to the content so i would like the entire div to be a link.

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 03 November 2007 - 12:25 PM

This question has been asked before, please use the forum search.

http://www.pixel2lif...showtopic=20224

#3 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 03 November 2007 - 03:08 PM

thats not it anyways.......thats to make a link inside a div, im looking to make a div the link itself.

#4 shameless_w_o_a_d

    Young Padawan

  • Members
  • Pip
  • 42 posts
  • Gender:Male
  • Location:New Zealand
  • Interests:Web Design, Graphics Design, Computers, Games, Music, Basketball

Posted 03 November 2007 - 06:41 PM

View PostHip Hop Artist, on Nov 4 2007, 09:08 AM, said:

thats not it anyways.......thats to make a link inside a div, im looking to make a div the link itself.

The link given does provide an option to allow a div to be clickable using JavaScript handlers.

But if you want to do it for simplicity sakes, then just wrap the div in particular in the <a> tag and I believe you'll have what you're wanting to accomplish. :google:

#5 Lastcrime

    Impatient Jedi that likes to eat cereal

  • Members
  • PipPipPip
  • 649 posts
  • Gender:Male
  • Location:Toronto, Ontario, Canada
  • Interests:Soccer, Snowboarding, Hockey, B-ball, Skateboarding, Computers!

Posted 03 November 2007 - 11:00 PM

wrapping the div in the <a> messes it up do this,

#div a:link, a:visited {
	  backgroundimage: blah;
	  font_decoration: none;
}
#div a:hover, a:active {
	  backgroundimage: blah;
	  font-decoration: underline;
}

You can replace the code with whatever you want but this will make your div clickable as a link. The html should look like this:

<div id="div">
	  <a href="b"> I like to go to the park </a>
</div>


#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 04 November 2007 - 01:24 AM

View PostHip Hop Artist, on Nov 3 2007, 02:08 PM, said:

thats not it anyways.......thats to make a link inside a div, im looking to make a div the link itself.
Please read the ENTIRE thread that i gave you. Trust me, i'm a professional.

http://www.pixel2life.com/forums/index.php...st&p=130771

View PostLastcrime, on Nov 3 2007, 10:00 PM, said:

wrapping the div in the <a> messes it up do this,
Well it should. It is invalid HTML to wrap a block level element in an inline element. What you have to do is set the <a> tag to display:block; (along with maybe a few other formatting corrections, depending on the circumstances), and that will fix the problem (but still won't make it validate).

#7 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 05 November 2007 - 08:00 AM

ok sorry rc69, and thanks for the help all!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users