vchris Posted May 15, 2006 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? Link to comment Share on other sites More sharing options...
aspnetguy Posted May 15, 2006 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> Link to comment Share on other sites More sharing options...
scott100 Posted May 15, 2006 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> Link to comment Share on other sites More sharing options...
boen_robot Posted May 15, 2006 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. Link to comment Share on other sites More sharing options...
vchris Posted May 15, 2006 Author Share Posted May 15, 2006 scott100 that's pretty much what I was thinking to do... Thanks Link to comment Share on other sites More sharing options...
vchris Posted May 15, 2006 Author 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.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now