Selection styling needs foreground and background colours that remain readable as a pair. Test actual selected text rather than an isolated colour chip.
Worked example
<style>
.demo::selection {
background: #fde68a;
color: #111827;
}
</style>
<p class="demo">Select this sentence to see the proof colour.</p>Implementation notes
A browser may limit which properties apply to the selection pseudo-element. Prefer a simple foreground-and-background pairing over relying on effects.
Try it yourself
Select across a link and its surrounding paragraph.
Open the CSS example →Editorial date February 10, 2026 · Published December 6, 2026