Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Adding a link within a div

  1. #1
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding a link within a div

    I want a main image in my site to link and it has a div attached to it and I can't figure out how to do it. The image I want to link is called main_img.

    How and where do I do it. The link I have added does not work!

    Can anyone help - thanks

    Code:
    </div>
    			<!-- end menu -->
    		</div>
    		<!-- end nav -->
    		<a href="httpwebsite.com" target="_blank"></a><div id="main_img"></div><!-- main img -->
    		<!-- start main text -->
    		<div id="main_text">
    			<div id="welcome">

  2. #2
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    your image should put between <a> </a>;

    for example:
    <a href="http://somesite.com">image go here</a>

  3. #3
    Join Date
    Feb 2008
    Location
    VietNam
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    This's my hint: <div><a><img></a></div>
    Code:
    <div><a href="http://vietgo.vn/index.aspx" target="_blank"><img style="border:none" src="http://i160.photobucket.com/albums/t189/kem_va_socola/login.gif" /></a></div><!-- main img -->

  4. #4
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thats great - thanks

    I now have this
    Code:
    		<div><a href="http://webaddress.com" target="_blank"><div id="main_img"></div></a></div>
    If you click the image it takes you off no problem however when you go over the image it doesnt come up as something to be clicked. ie cursor remains as an arrow and not the hand/thumb icon...if you know what I mean?

    How do I get it so that when you roll over the image it comes up as something to click (like a button)

    Thanks

  5. #5
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Try adding &nbsp; or better a Click Here inside your main_img div.
    Or...if you only want the cursor to change, when hovered on the image...you could just add style="cursor: pointer;" in
    div id="main_img">
    See if it helps
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  6. #6
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Brilliant - thanks

    I now have
    Code:
    		<div><a href="http://webaddress.com" target="_blank"><div id="main_img"style="cursor: pointer;"  ></div></a></div>
    I tried to ad an 'alt' to the image but this didn't work. Like this

    Code:
    <div><a href="http://webaddress.com" target="_blank"><div id="main_img"style="cursor: pointer;"alt="Message" ></div></a></div>[
    How/where do I add the alt

    Thanks again!

  7. #7
    Join Date
    Feb 2008
    Location
    VietNam
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <div><a href="http://vietgo.vn/index.aspx" target="_blank"><img style="border:none; cursor: pointer" alt="Message" src="http://i160.photobucket.com/albums/t189/kem_va_socola/login.gif" /></a></div><!-- main img -->
    Hope that code may help u!

  8. #8
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Isn't that what I did tho??

    I think I am putting the alt code in the wrong place

    Can anyone show me where to put it in my code?

    Thanks

  9. #9
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Hi bob23,
    The alt is place in the image (<img>) tag not in the div tag.. and note that firefox don't understand alt instead use title.

    In your code, it should be:
    Code:
    <div><a href="http://webaddress.com" target="_blank" alt="message"><div id="main_img"style="cursor: pointer;"></div></a></div>
    Youre error is that you place it in the div...I quoted it for you:
    <div><a href="http://webaddress.com" target="_blank"><div id="main_img"style="cursor: pointer;"alt="Message" ></div></a></div>
    See if it helps
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  10. #10
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Am I missing something This is now my code

    Code:
    <div><a href="http://webaddress.com" target="_blank" alt="message"><div id="main_img"style="cursor: pointer;"></div></a></div>
    But it isnt working? what silly mistake have I done?!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •