![]() |
VOOZH | about |
The ::selection CSS pseudo-element allows you to style the part of a webpage that users highlight, such as when they drag the mouse over text. Itβs a simple way for developers to customize the appearance of selected text, improving the overall user experience. However, only a few CSS properties can be used with :: selection, including color, background, cursor, and outline.
The ::selection pseudo-element applies specific styles to the portion of a webpage that the user selects. This is particularly useful for enhancing the readability and visual appeal of highlighted text.
::selection {
// CSS Property
}Example: In this example, we demonstrate how the ::selection pseudo-element is used to change the text color to white and the green background when the user highlights any text on the page.
Output:
The ::selection selector is supported by the following browsers:
Note: For older versions of Firefox, use the ::-moz-selection selector to ensure proper functionality.