Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overriding Styles

Status
Not open for further replies.

Nevermoor

Programmer
Jul 25, 2003
218
US
I have a page where the CSS file says:
a:hover {border: solid 1px #AF0807;} but I can't seem to remove that border from images within links. (especially annoying as firefox only draws the border around the bottom 12 pixels of the picture)

My guesses such as
img {
border: 0px none;
}
a:hover>img {
border: 0px none;
}
img>a:hover {
border: 0px none;
}
don't seem to work
 
sorry to take so long responding, but I can't seem to make that work.

Are you suggesting giving a class to all images within links and define for that class?

There must be some CSS pattern for images within links that takes precedence over the basic
a:hover {
color: #000000;
border: solid 1px #AF0807;
text-decoration:none;
}
definition.
 
Give the image a class without borders and the same for the links. something like;
Code:
img.link {
	border:0px none;
}
a.image:link {
	border:0px none;
}
a.image:visited {
	border:0px none;
}
a.image:active{
	border:0px none;
}
a.image:hover {
	border:0px none;
}



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Your problem is that the <a> tag has the border, not the image. So all your CSS attempts to remove borders from images within links come to nought - the image doesn't have a border, the link does.

I don't think there's any way you can define a rule in CSS to select elements that contain particular other elements (as opposed to selecting elements contained in others), so you'll have to use Chris's solution of applying a class to image links.

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top