473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

[CSS] How to combine anchor tags w/o underlining images on hover

DC
Given:

a {
text-decoration:none;
}

a:hover {
text-decoration:underline;
}
Case #1

<p>
<a href="http://www.conservative.ca/">
<img src="images/logo_cpc_e.png" />
Conservative Party of Canada
</a>
</p>
Case #2

<p>
<a href="http://www.conservative.ca/">
<img src="images/logo_cpc_e.png" />
</a>
<a href="http://www.conservative.ca/">
Conservative Party of Canada
</a>
</p>

* markup simplified for clarity (I'm not an idiot }:O)
PROBLEM:

Same css for both cases. In case #1 (shared anchor tag), hover causes img to
be underlined along with the link text. Ugly. However, in case #2, img not
underlined on hover.

Why?

I don't want the unnecessary bloat from duplicating anchor tags. Can I
achieve this with css? What am I doing wrong? I'm sure it is something
simple but I can't suss it.

Thanks.

--
DC Linux RU #1000111011000111001

The word 'politics' is derived from the word 'poly', meaning 'many'
and the word 'ticks', meaning 'blood sucking parasites'.
Jan 10 '06 #1
3 2626
Deciding to do something for the good of humanity, DC
<dc*****@myrealbox.com> spouted in
comp.infosystems.www.authoring.stylesheets:
Same css for both cases. In case #1 (shared anchor tag), hover causes img to
be underlined along with the link text. Ugly. However, in case #2, img not
underlined on hover.


That does seem odd. URL? What browser(s)?

--
Mark Parnell
================================================== ===
Att. Google Groups users - this is your last warning:
http://www.safalra.com/special/googlegroupsreply/
Jan 10 '06 #2
Els
Mark Parnell wrote:
Deciding to do something for the good of humanity, DC
<dc*****@myrealbox.com> spouted in
comp.infosystems.www.authoring.stylesheets:
Same css for both cases. In case #1 (shared anchor tag), hover causes img to
be underlined along with the link text. Ugly. However, in case #2, img not
underlined on hover.


That does seem odd. URL? What browser(s)?


Reproducable in Firefox (tested in v1.5). Only works as long as the
image is inline - float it and the image won't be underlined
However, if you look closely on case #2, hovering the image will show
the space between the image and the text underlined.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: At The Drive In - Cosmonaut
Jan 10 '06 #3
DC wrote:

PROBLEM:

Same css for both cases. In case #1 (shared anchor tag), hover causes img to
be underlined along with the link text. Ugly. However, in case #2, img not
underlined on hover.

Why?

I don't want the unnecessary bloat from duplicating anchor tags. Can I
achieve this with css? What am I doing wrong? I'm sure it is something
simple but I can't suss it.


Best I've ever been able to do is something like:

a {
text-decoration: none;
}

a span {
text-decoration: underline;
}

<a href="#"><img src="image.gif"> <span>Link text here</span></a>

Not all that great, & I'm certainly open to a better solution - but
that's what has worked for me in the past. Especially given that
Firefox underlines the whole link

Haven't tried it with the underline for hovers only, though.

Jan 12 '06 #4

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

Similar topics

7
by: LRW | last post by:
Below I'll paste my CSS and the HTML in question. But what's happening is, I'm trying to establish a link behavior for a class that's separate from the normal link class. I've established a: 's...
3
by: Alex | last post by:
Hi all, Thanks to Els from another post I got my CSS hover-overs working in IE, Firefox, and about everything else I've tried. Problem is the CSS hover overs are VERY choppy in IE while very...
4
by: jereme.goblue | last post by:
The web page at http://www.rossowinspections.com/ has an issue with the left menu. The left menu has 7 links. One of the links doesn't work. Using Firefox 1.5 the Fees link isn't a clickable...
0
by: jereme.goblue | last post by:
The web page at http://www.rossowinspections.com/ has an issue with the left menu. The left menu has 7 links. One of the links doesn't work. Using Firefox 1.5 the Fees link isn't a clickable...
1
by: cwrinn | last post by:
<html> <head> <style type="text/css"> h1.visible {display: block; position: absolute; top: 100px;} h1.invisible {display: none; position: absolute; top: 100px;} a.anchor:hover h1.visible...
5
by: Bubba | last post by:
I need to use an inline css tag for a few links that will not behave like the a:link and a:hover attributes in my stylesheet. I want to add a special link color with underline and a mouseover...
11
victorduwon
by: victorduwon | last post by:
Hey guys, I have built a suckerfish navigation menu using CSS and HTML with unordered lists. I was testing this menu in Safari, and it came out good. When I finished I tested it in firefox and...
3
by: Steve | last post by:
Hi All I have an asp.net 2.0 website with the following css file It uses Master pages and in Firefox 3.04 for windows only, 3 of the web pages don't display the Master page properly The...
8
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.