::selection { background: #000000; color: #ffffff }
Is resulting in a dark grey selection color, not full black (#000000
). Changing opacity makes no difference.
How do I make the selection color appear as #ffffff
?
The ::selection selector matches the portion of an element that is selected by a user. Only a few CSS properties can be applied to the ::selection selector: color, background, cursor, and outline.
To change the selected option background-color CSS style, we can set the style attribute of the select and option elements. to set the whole select element to background color 009966 and color FFF . Then we override the the styles in the option elements with style="background: white; color: black;" .
You can change the background color and color of selected text by styling ::selection . Styling this pseudo element is great for matching user-selected text to your sites color scheme.
This worked for me:
::selection {
background: rgba(0, 0, 0, 0.99);
color: #FFF;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With