Css Selection Property - Youtube Apr 2026
/* Styling for the whole page */ ::selection { background-color: #ffb7b7; color: #000; } /* Styling for a specific paragraph class */ .custom-highlight::selection { background-color: yellow; color: red; } Use code with caution. Related Properties
The pseudo-element in CSS is used to style the part of a document that is currently highlighted or "selected" by the user (for example, with a mouse click and drag). Key Properties for ::selection CSS Selection Property - YouTube
To change the highlight of an entire webpage to a custom color, you can apply it to the root or a specific element: /* Styling for the whole page */ ::selection
Only a limited set of CSS properties can be used with ::selection , as browsers restrict them for performance and usability reasons: : Sets the color of the selected text. background-color : Sets the highlight color behind the text. text-shadow : Adds a shadow effect to the selected text. background-color : Sets the highlight color behind the text
: A modern property used to style interactive elements like checkboxes or radio buttons, distinct from text selection.