473,695 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image Link with Border

Hi,

I'm looking for a way to put a 1px solid border around the image in this
link:
<a href="some.html "><img src="some.gif"> </a>
Well, that, by itself, is simple. However, I would like to have a different
border color for a mouse hover effect over the image. With Mozilla, I can
simply specify img:hover {...}, but IE allows hover only for <a>. So now I'm
looking for a way to set the border for my <a> element rather than the
<img>, but here I encounter some problems. It seems, I must specify a
width:0px, to make IE show the border (tested IE5). But I wasn't able to
make the <a>-border appear in Mozilla.

The following works with IE5, but not Mozilla (not even when I remove the
width:0px).

<a href="some.html " class="imagebor der"><img src="some.jpg" border="0"></a>

..imageborder
{
width:0px;
cursor:hand;
border:1px solid black;
}

..imageborder:h over
{
border:1px solid red;
}

What can I do to make this compatible with "all" browsers?

(P.S.: NN4 doesn't like borders around images, but when I put the border in
the <a> element instead, is there a way to have NN4 display it properly -
even though NN4 will not support the hover effect?)

Greetings,
Thomas
Jul 20 '05 #1
33 27746
Els
Thomas Mlynarczyk wrote:
Hi,

I'm looking for a way to put a 1px solid border around the image in this
link:
<a href="some.html "><img src="some.gif"> </a>
Well, that, by itself, is simple. However, I would like to have a different
border color for a mouse hover effect over the image. With Mozilla, I can
simply specify img:hover {...}, but IE allows hover only for <a>. So now I'm
looking for a way to set the border for my <a> element rather than the
<img>, but here I encounter some problems. It seems, I must specify a
width:0px, to make IE show the border (tested IE5). But I wasn't able to
make the <a>-border appear in Mozilla.

The following works with IE5, but not Mozilla (not even when I remove the
width:0px).

<a href="some.html " class="imagebor der"><img src="some.jpg" border="0"></a>

.imageborder
{
width:0px;
cursor:hand;
border:1px solid black;
}

.imageborder:ho ver
{
border:1px solid red;
}

What can I do to make this compatible with "all" browsers?

(P.S.: NN4 doesn't like borders around images, but when I put the border in
the <a> element instead, is there a way to have NN4 display it properly -
even though NN4 will not support the hover effect?)


Sorry, can't test for NN4, but i make my image links with
borders like this, which works in IE, NS 7, Opera, Mozilla's
Firebird..

a:link img{text-decoration: none;
border-color: red;
border-width: 2px;
}

a:visited img{text-decoration: none;
border-color: yellow;
border-width: 2px;
}

a:hover img{text-decoration: none;
border-color: green;
border-width: 2px;
}

hth

--
Els

A mente é egual á uma paraqueda; funciona melhor aberta.

Jul 20 '05 #2
Also sprach Els:
Sorry, can't test for NN4, but i make my image links with
borders like this, which works in IE, NS 7, Opera, Mozilla's
Firebird..

a:link img{text-decoration: none;
border-color: red;
border-width: 2px;
}

a:visited img{text-decoration: none;
border-color: yellow;
border-width: 2px;
}

a:hover img{text-decoration: none;
border-color: green;
border-width: 2px;
}


Unfortunately, the green "hover" effect does not show on IE5 - I just
checked it. That's why I was looking for a way to put the border in the <a>
element instead of the <img> as your code does. Still, the combination
"a:hover img" is interesting.

Jul 20 '05 #3
Els
Thomas Mlynarczyk wrote:
Also sprach Els:

Sorry, can't test for NN4, but i make my image links with
borders like this, which works in IE, NS 7, Opera, Mozilla's
Firebird..

a:link img{text-decoration: none;
border-color: red;
border-width: 2px;
}

a:visited img{text-decoration: none;
border-color: yellow;
border-width: 2px;
}

a:hover img{text-decoration: none;
border-color: green;
border-width: 2px;
}

Unfortunately, the green "hover" effect does not show on IE5 - I just
checked it. That's why I was looking for a way to put the border in the <a>
element instead of the <img> as your code does. Still, the combination
"a:hover img" is interesting.


This I don't get. Have a look at
http://www.mediatech.nl/~rachel/Fram...chel/live.html
in IE 5. If you hover over the pics, you don't see a
purpleish border??
It is the start (only testing a few pages yet) of a new
version of a site which I actually made using IE 5!
If it works, check out the stylesheet...
I used "td a:hover img", because I wanted the border only on
the pics inside the table, not the images outside it...

--
Els

A mente é egual á uma paraqueda; funciona melhor aberta.

Jul 20 '05 #4
Els
Els wrote:
Els wrote:
Thomas Mlynarczyk wrote:
Also sprach Els:
Sorry, can't test for NN4, but i make my image links with
borders like this, which works in IE, NS 7, Opera, Mozilla's
Firebird..

a:link img{text-decoration: none;
border-color: red;
border-width: 2px;
}

a:visited img{text-decoration: none;
border-color: yellow;
border-width: 2px;
}

a:hover img{text-decoration: none;
border-color: green;
border-width: 2px;
}


Unfortunately, the green "hover" effect does not show on IE5 - I just
checked it. That's why I was looking for a way to put the border in
the <a>
element instead of the <img> as your code does. Still, the combination
"a:hover img" is interesting.


This I don't get. Have a look at
http://www.mediatech.nl/~rachel/Fram...chel/live.html in IE 5. If
you hover over the pics, you don't see a purpleish border??
It is the start (only testing a few pages yet) of a new version of a
site which I actually made using IE 5!
If it works, check out the stylesheet...
I used "td a:hover img", because I wanted the border only on the pics
inside the table, not the images outside it...

Sorry, got it, I thought it would work the way I wrote earlier, but it
doesn't. (not even in IE 6.0 :-))
The way it works is like this:

a:link {text-decoration: none;
color: red;
}

a:visited {text-decoration: none;
color: green;
}

a:hover {text-decoration: none;
color: yellow;
}

a:link img{border-color: white;
border-width: 2px;
}

a:visited img{border-color: orange;
border-width: 2px;
}

a:hover img{border-color: blue;
border-width: 2px;
}

For some reason, the regular links have to be mentioned as well.
Tested it this time :-)


Why don't I just test everything before I send a message!
Figured out, that if you leave out the regular links (just
in case you don't have any text-links), but still only put
a:hover {color:green;}, it does work too. - any color will
be good :-) and text-decoration:none is just something I
used, there is no need for that either.

--
Els

A mente é egual á uma paraqueda; funciona melhor aberta.

Jul 20 '05 #5
Thanks a lot, Els!

After having read your fist post (with the example site) I went there and
did about half an hour of work to figure out why it worked there but not on
my site - after having found out, I read your other posts :-) It's weird
that one must put an a:hover{whateve r} to make IE do the hover effect. Now
it works on IE5, NN6, Mozilla 1.1 and OP7 (as tested by myself, I'll test
some other browsers later), NN4 and OP6 show no borders at all (For NN4 it's
normal since I hid them from it, don't know why OP6 doesn't show them, but
anyway it's okay, I can live with that).

Thanks again and greetings,

Thomas
Jul 20 '05 #6
"Els" <el*********@PL EASEtiscali.nl. invalid> schrieb im Newsbeitrag
news:bh******** **@reader1.tisc ali.nl...
Thomas Mlynarczyk wrote:

(Now I want to find out why it doesn't work in my Operas! ;-))


Els...

I am sorry I can't tell you about Opera, but you should absolutely avoid the
<div style="..."> syntax which totally messes up the page in Netscape 4 (on
both my Mac and PC). Use <div id="..."> instead and specify the style in the
stylesheet.

--
Markus
Jul 20 '05 #7
Also sprach Els:
Can anyone give me a link to an explanation of what exactly
is 'seen' and 'not seen' by Netscape 4?


Do you mean something like this:
http://www.richinstyle.com/bugs/netscape4.html


Jul 20 '05 #8
Els
Els wrote:
Markus Ernst wrote:
"Els" <el*********@PL EASEtiscali.nl. invalid> schrieb im Newsbeitrag
news:bh******** **@reader1.tisc ali.nl...
Thomas Mlynarczyk wrote:

(Now I want to find out why it doesn't work in my Operas! ;-))

And about Opera, I think I have figured it out, I'll report here after
I've tested my idea :-)


Found it. Something logical, but IE isn't that logical
apparently :-)
To display the border on hover, Opera needs to know what
style it is, so I put border: 2px solid instead of
border-width: 2px. That made Opera do what I want.

But: then IE displays the wrong colour border.
So I changed
td a:hover img{border-color: rgb(171,7,247);
border-width: 2px solid;}
to
td a:hover img{border: 2px solid rgb(171,7,247); }

(also on 'td a:link img' and 'td a:visited img')

and now it works in Opera as well as IE...
(IE is strange!!)

Thanks for putting your code here, Thomas, it made it easy
for me to find what was wrong.

But now there's something strange going on in NS 7.1, but
that happens to your
http://www.mlynarczyk-webdesign.de/borderhover.html
as well...

It appears to have something to do with underlining, as soon
as I find out exactly, I'll be back here ;-)
--
Els

A mente é egual á uma paraqueda; funciona melhor aberta.

Jul 20 '05 #9
Els
Els wrote:
Els wrote:
Markus Ernst wrote:
"Els" <el*********@PL EASEtiscali.nl. invalid> schrieb im Newsbeitrag
news:bh******** **@reader1.tisc ali.nl...

Thomas Mlynarczyk wrote:

(Now I want to find out why it doesn't work in my Operas! ;-))

And about Opera, I think I have figured it out, I'll report here after
I've tested my idea :-)

Found it. Something logical, but IE isn't that logical apparently :-)
To display the border on hover, Opera needs to know what style it is, so
I put border: 2px solid instead of border-width: 2px. That made Opera do
what I want.

But: then IE displays the wrong colour border.
So I changed
td a:hover img{border-color: rgb(171,7,247);
border-width: 2px solid;}
to
td a:hover img{border: 2px solid rgb(171,7,247); }

(also on 'td a:link img' and 'td a:visited img')

and now it works in Opera as well as IE...
(IE is strange!!)

Thanks for putting your code here, Thomas, it made it easy for me to
find what was wrong.

But now there's something strange going on in NS 7.1, but that happens
to your http://www.mlynarczyk-webdesign.de/borderhover.html
as well...

It appears to have something to do with underlining, as soon as I find
out exactly, I'll be back here ;-)


Right. the 'strange' thing in NS 7.1 was there in the other
browsers too (not with your page), but less 'jumpy', so I
didn't notice it.
I fixed it now, by adding 'text-decoration: none' to all the
img link,visited,ho ver styles. Works fine now in "any" browser.

But now your example page.
As the borders (on hover) add to the height of the picure,
there's a green line between the bottom of the photo and the
frame. (repetition of the bgm.gif)
In Netscape, the borders don't show before you hover, so it
jumps when you do.

The funny thing is, that if you take out now the
'a:hover{text-decoration:none ;}' which we thought it needed,
the pages works just fine.

-- was I wrong yesterday, or am I wrong now??? -- :-)

Just alter the height of the picture or the bgm.gif, and the
green line will disappear as well.

--
Els

A mente é egual á uma paraqueda; funciona melhor aberta.

Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3282
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
5
3479
by: Chris Beall | last post by:
I'm displaying an image that is also a link against a black background. In Netscape 7.1, the current background color is displayed as a horizontal bar below the image. This allows :hover effects that change the background color to have a visible effect, as this bar changes color. By default, it appears that the color is inherited from the body color, i.e. with no link style applied, the bar is black, and invisible against the background....
8
12794
by: JLahm | last post by:
I have defined a class for my images called .image that specifies the default border color, width and style. I'd like to be able to have the pseudo elements link, visited and active have one color and style, while the hover class has a different color and style. I have the entries: a:link .image { border-color: #151515; border-style: solid; border-width: 2px; }
9
2043
by: Karl Burrows | last post by:
I am working on a Website for a non-profit group and for some reason I have one link that doesn't want to cooperate. All the image links work fine with the onmouseover and onmouseout script except one. Maybe I am just getting blurry-eyed, but can someone help me figure out what I have done wrong? Thanks!!!! <td width="190" height="57"><a href="Trends.htm" onmouseover="chgImg('Trends','InteriorTrendsBold')"...
2
6762
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not set image width. This problem makes my link clickable only on its borders. When viewing HTML source I could see that spacer.gif has no width and height, so HTML shows only 1px x 1 px image.
0
1823
by: wizardworkz | last post by:
Hello All! Having a bit of a problem combining php with javascript here. What I have is a store with images (There will be a smaller image of each item, and a larger image of each item, but I want users to click on a link under the image shown (Smaller image) for a popup window showing a larger image. I have already setup an additional table line named "image2" and want the image be puleed from the db (images folder) to pop up to a window...
7
17274
by: Cate Archer | last post by:
I want to have a border around an image that changes color when the mouse hovers over it. The following code works perfectly in FireFox but not in Internet Exploiter. The text link changes color but the image link stays the same. Anybody know how I can make it work in IE? I saw a web site where the guy got it to work in both browsers. <html> <head> <title>TEST</title>
1
3142
by: rsteph | last post by:
I've got some product information pages, with images and text, all setup within a table. I'm trying to add a small image in the upper right hand corner of the content div (where all the important information is). I've got the product name at the top, left aligned and typically as a two lined header, and I'd like to add a small logo to the right of that, either right beside it, or in the far right corner. could anyone help me with how to set...
2
4092
by: studentofknowledge | last post by:
For some unknown reason ie is placing images I have in a div in a weird way. One image is overlapping another but this problem is not occuring in mozilla. I have looked at my code over and over again but cant seem to find out what the problem is. I think this could be fixed with a i.e hack??? please advise the problem of the overlapping image is occuring in imagerow2 div on line 56. please see my code below here is my html <!DOCTYPE...
0
8553
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9112
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8822
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5827
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4332
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.