Mo Green Posted March 11, 2020 Share Posted March 11, 2020 (edited) Hello together, I am learning CSS as a beginner and i dont understand, why the pseudoelement ::selection is classified as a pseudoelement and not as a pseudoclass. I learned that a pseudoelement is by definition something, that separates a certain part of an existing element and styles this part with special instructions. But the selection-pseudoelement does not do this. It does not have to relate to a specific element, but can relate to every content the browseruser marks with the cursor. The content does not even have to be signed with markup to be selected by the ::selection-pseudoelement. Can anybody explain to me, why ::selection is categorized as pseudoelement? In my understanding it would fit much more into a dynamic pseudo-class, because it reacts to a userinteraction=the marking with the cursor. Thank you for answers and best regards, Mo Edited March 11, 2020 by Mo Green Link to comment Share on other sites More sharing options...
Ingolme Posted March 12, 2020 Share Posted March 12, 2020 It's a pseudo-element because a new element is created wrapped around the selected text. A pseudo-class is when a class is added to an existing element under certain circumstances. 1 Link to comment Share on other sites More sharing options...
Mo Green Posted March 24, 2020 Author Share Posted March 24, 2020 Thank you for the answer. That makes it clear for me now. :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now