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 trialGavin Johnston
9,107 PointsHow to apply styles to a previous CSS sibling?
The below code would turn box-2 red when box-1 is activated. Because box-2 follows box-1 in html. So how would I turn box-1 red when box-2 is activated given that the sibling combinator only works on and siblings that come next?
.box-1:active ~ .box-2 {
background-color: red;
}
Thanks!
1 Answer
Peter Vann
36,427 PointsHi Gavin!
This thread seems to address your issue:
https://stackoverflow.com/questions/1817792/is-there-a-previous-sibling-selector
I hope that helps.
Stay safe and happy coding!
Gavin Johnston
9,107 PointsGavin Johnston
9,107 PointsThanks Peter!