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 trialJohn Fisher
7,974 PointsWhat's the difference between a Pseudo Class and a Pseudo Element?
Having trouble grasping the exact difference between Pseudo Class and a Pseudo Element. Can someone explain it in simple terms? thanks.
2 Answers
John Breslin
16,963 PointsPseudo classes are for selecting elements that exist but you can't select with the DOM. There's no way to tell what div being hovered in the markup, it depends on the action of the user. The div exists, but there's no way to select it with a normal class. Pseudo classes can be chained and used like a regular classes.
A pseudo element selects elements that don't exist, creating a new virtual element. For instance, there's no tags for the first-line of an element. So it's like ::first-line is creating virtual tags to make it select-able. You can only use one pseudo element per selector, unlike Pseudo classes.
Hope this helps.
John Fisher
7,974 PointsI think I understand that...
Thanks for your help.
John Breslin
16,963 PointsNo problem.