Log in

View Full Version : Adding a link within a div



bob23
02-20-2008, 04:42 PM
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:)


</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">

lsio83
02-20-2008, 05:34 PM
your image should put between <a> </a>;

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

Kem
02-21-2008, 02:31 AM
This's my hint: <div><a><img></a></div>

<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 -->

bob23
02-21-2008, 10:10 AM
Thats great - thanks:)

I now have this

<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

rangana
02-21-2008, 10:16 AM
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 :D

bob23
02-21-2008, 10:51 AM
Brilliant - thanks

I now have

<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


<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:confused:

Thanks again!:o

Kem
02-21-2008, 12:57 PM
<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!

bob23
02-21-2008, 01:16 PM
Isn't that what I did tho??:confused:

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

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

Thanks

rangana
02-22-2008, 01:54 AM
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:


<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:D

bob23
02-22-2008, 11:38 AM
Am I missing something:confused: This is now my 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?!!:rolleyes:

rangana
02-22-2008, 11:50 AM
You forget to hit the space bar on
main_img"style="cursor: pointer;"

This should work:
[code]
<div>
<a href="http://webaddress.com" target="_blank" alt="message">
<div id="main_img" style="cursor: pointer;">This should contain a message or else nothing will be visible for click</div></a></div>[code]

See if it helps :D

bob23
02-22-2008, 12:51 PM
I now have


<div><a href="http://webaddress.com" target="_blank" alt="message"><div id="main_img" style="cursor: pointer;"></div></a></div>

as before the link works and the pointer works but I want the alt message to come up when someone goes over it (set as tex - 'message' until I get it working). It still doesnt do this:confused:

any ideas why??

Thanks for looking at this, really appreciate it

rangana
02-23-2008, 04:41 AM
Hi bob23,
alt attribute only works in image tag..and specifically in IE. It wil not work inside the <a> tag.