How to style a link with CSS to change border color of image, but not add border around text?

I have CSS like this:

.videothumb{border:2px solid #2e2e2d;padding:4px;}
a.videolink,a.videolink:visited{color:#7d7c7b;text-decoration:none;}
a.videolink:hover{color:#7d7c7b;text-decoration:underline;border:2px solid #676765;}

Open in new window


My HTML link looks like this:

<a href="#"><img class="videothumb" src="img/img.jpg"><br />
Some text here</a>

Open in new window


So, I want a hover event to change the color of the border around the image but not add a border around the text part of the link, which is what it is doing currently.

I had also tried this:

.videothumb:hover{border:2px solid #676765}

Open in new window


That worked nicely for the image, but if you took the mouse off the image and just on the text part of the link, the border highlight would go away.

There must be some compromise between these two methods that will do what I want? Thank you!
Brad BansnerWeb DeveloperAsked:
Who is Participating?
 
Kyle HamiltonConnect With a Mentor Data ScientistCommented:
your style rule revised. it was incorrect.

.videolink:hover .videothumb{
   border:2px solid #676765;
      }

<a class="videolink" href="videos.php?v=1"><img class="videothumb videospaceright" src="img/gr_video-1.jpg" width="149" height="84" border="0" /><br />
                        John Badal speaks...</a>
0
 
Kyle HamiltonData ScientistCommented:
give the link a class:
<a href="#" class="thumblink"><img class="videothumb" src="img/img.jpg"><br />
Some text here</a>

Open in new window


then in css:
.thumblink:hover .videothumb{border:2px solid #676765}

Open in new window




is this what you're looking for?
0
 
Brad BansnerWeb DeveloperAuthor Commented:
That didn't quite do it. Lets make this easier, here is my test page:
http://www.partnersdesign.net/lieverhymanpotter/videos.php

Here is the HTML and CSS I tried adding, based on your suggestion:

.videolink:hover{
		.videothumb{border:2px solid #676765;}
	}

<a class="videolink" href="videos.php?v=1"><img class="videothumb videospaceright" src="img/gr_video-1.jpg" width="149" height="84" border="0" /><br />
				John Badal speaks...</a>

Open in new window

0
 
Brad BansnerWeb DeveloperAuthor Commented:
Perfect, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.