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 trialRam Ada
360 PointsGrouping Pseudo selectors
I have two pseudo selectors how do I group them?
input[type="text"]:hover { border: 1px solid rgba(2,73,48,.5); }
input[type="text"]:focus { border: 1px solid rgba(2,73,48,.5); }
I've tried:
input[type="text"]:hover:focus { }
and
input[type="text"]:hover, :focus { }
and
input[type="text"] :hover, :focus { }
None of these seem to work. Any advice? Thank you!
2 Answers
Keith Wyland
10,576 PointsHi Ram,
You're on the right track with adding a comma and then the next selector. You just need to add the full selector rule after the comma. So if I wanted to select a
tags both when they are hovered and active I would do:
a:hover, a:active {
border: 1px solid black;
}
Does that help?
Ram Ada
360 PointsThanks Keith! It worked.
James Barnett
39,199 PointsIf you need anymore info, here's a great run down on how you can group selectors together
Remember, the only difference between grouping selectors and grouping psuedo-selectors is that later can be chained together.
Arijit Bhattacharya
4,563 PointsArijit Bhattacharya
4,563 PointsHey Ram, this is sort of a roundup of important CSS Selectors. You may find it useful.