Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Vilius Grižas
Vilius Grižas
2,753 Points

Link doesn't change color with a:link property, but does with a:hover one.

Hey all.

This is my code. I'm trying to make my header to be white, but it stays blue all the time. I tried to see if after puting a:hover something changes and it does. When I hover on it it turns white, but when it's simply there it stays blue all the time.

And there's nothing with blue that I've written in that code. Plus this code that is copied here is the last in the file so nothing's overwriting it.

Any ideas? :)

header h3 a:link{ text-decoration:none; font-family: 'Titillium Web', sans-serif; font-weight:400; color:white; } header h3 a:hover{ color:white; }

4 Answers

Julian Gutierrez
Julian Gutierrez
19,201 Points

The blue color is probably just the browsers default color for links. Try just targeting the anchor tag in your css.

a{
    color:#ffffff;
}

or

header h3 a{
    color:#ffffff;
}
Vilius Grižas
Vilius Grižas
2,753 Points

Yes, it helped. But I don't understand why. Howcome

header h3 a:link{   
    color:white;
}

doesn't work and

header h3 a{
    color:white;
}

does?

Julian Gutierrez
Julian Gutierrez
19,201 Points

Do your links have an href associated to them?

Vilius Grižas
Vilius Grižas
2,753 Points

If by href you mean a link then yes, they do.

Thanks for the help by the way! :)

Julian Gutierrez
Julian Gutierrez
19,201 Points

I don't use the link pseudo class too much but my understanding was that an anchor without an href will not be affected by the link pseudo class. In the below example only the second link would be red.

<a>This is a link</a>
<a href="#">This is also a link</a>    
a:link{
  color:red;
}
Vilius Grižas
Vilius Grižas
2,753 Points

I think the whole point of using an anchor is to put a href inside it isn't it? But anyway, thank you, it helped :) Next time I'll keep this in mind! Cheers

Julian Gutierrez
Julian Gutierrez
19,201 Points

I agree, which is why targeting the anchor tag without a pseudo class has always been enough for me.