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 CSS Foundations Advanced Selectors Substring Matching Attribute Selectors

Ariel Vainer
Ariel Vainer
7,042 Points

How can I combine Link and User Action Pseudo-Classes and Substring Matching Attribute Selectors?

For example I have:

a[href^="http:"]{

}

and

a:hover{ color:white; }

I want that every a that starts with http has that hover value... Its possible or do I need to use classes?

1 Answer

Hugo Paz
Hugo Paz
15,622 Points

Hi Ariel,

Just add the pseudo class to the matching attribute like so:

a[href^='http:']:hover{
    color:tomato;
}
Ariel Vainer
Ariel Vainer
7,042 Points

Great! Thank you!! Happy New Year!