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 trialLi Mbo
5,096 Pointswhat does :root actually do and for what do we need it?
Is it similar to head{} ?
1 Answer
sean murphy
9,435 PointsThe :root selector always you to grab the highest parent in the document tree. Most of the time, this will be no different than html{}; The time you will use the psuedo-class over the standard html element comes when you are dealing with other document formats. CSS isn't just for HTML! It can also be used for SVG, XML, or XUL. In these cases, when creating a stylesheet, html would be an invalid selector, and you would instead use :root{}
:root also has a higher specificity than HTML!
Li Mbo
5,096 PointsLi Mbo
5,096 PointsVery quick answer, clear and to the point, thanks a lot Sean!