vchris 3 Posted May 15, 2006 Report Share Posted May 15, 2006 I think the title says it pretty clearly!Basically I have a link <a href="#">blah</a> and on hover I want the b to change to red let's say. The whole word is the link but only the b would change color on hover.This is only done in the navigation. I thought of doing two <a> tags for every link but is there a way with only css? Quote Link to post Share on other sites
aspnetguy 30 Posted May 15, 2006 Report Share Posted May 15, 2006 I don't know how to do it with only css, or if you even can.Try this <a href="url" onmouseover="this.getElementsByTagName('span')[0].style.color='your color'"><span>b</span>lah</a> Quote Link to post Share on other sites
scott100 1 Posted May 15, 2006 Report Share Posted May 15, 2006 This is the best i can offer split the <a> with a <span> and colour differently <head><style>a.example{color: blue;text-decoration:none;}a:hover.example{color: red;} a.example span{color: blue;}a:hover.example span{color: blue;} </style></head><body><h1><a href="#" class="example">B<span>lah</span></a></h1></body> Quote Link to post Share on other sites
boen_robot 107 Posted May 15, 2006 Report Share Posted May 15, 2006 Wouldn't a simple usage of the :first-letter pseudo class do the trick? a:first-letter:hover {color: red} both IE and FF support it if we can trust the W3Schools' CSS reference. Quote Link to post Share on other sites
vchris 3 Posted May 15, 2006 Author Report Share Posted May 15, 2006 scott100 that's pretty much what I was thinking to do... Thanks Quote Link to post Share on other sites
vchris 3 Posted May 15, 2006 Author Report Share Posted May 15, 2006 Wouldn't a simple usage of the :first-letter pseudo class do the trick?a:first-letter:hover {color: red} both IE and FF supported if we can trust the W3Schools' CSS reference. <{POST_SNAPBACK}> Tried it and the whole word lights up.... Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.