CSS
Use the ::selection pseudo-element:
Firefox legacy note: ::-moz-selection was required historically; modern Firefox supports the unprefixed form.
Only these properties work inside ::selection: color, background-color, text-shadow, text-decoration, -webkit-text-stroke.
Tailwind
Use the selection: variant:
The variant cascades: applying it to a parent styles selection for all descendants. Arbitrary values work: selection:bg-[#ff00aa].
::selection { background-color: #6366f1; color: #ffffff;}
/* Scoped to an element */p::selection { background-color: #fbbf24; color: #000000;}
Text hereNo comments yet. Be the first to share your thoughts.