Back to all resources
CSS
::selection
text selection

Text Highlight Color

By Jared Malan
This CSS code snippet defines the appearance of text when it is selected by the user. The ::selection pseudo-element is used to apply styles to the portion of a document that has been highlighted by the user, typically by clicking and dragging the mouse over text. In this case, the background color of the selected text is set to black (#000000), and the color of the text itself is set to white (#ffffff). This creates a high-contrast visual effect that makes the selected text stand out clearly against the rest of the content.