Select any fragment inside the block to see how the highlight changes.
Selection highlight
Selecting text is a native browser interaction. ::selection lets you customize the background color, text color, decoration, and shadow applied to the selected fragment.
Try changing the selector scope: global mode affects this whole preview and scoped mode only affects the editorial block.
HTML
Copy HTML
<p>Select any fragment in the article to review the generated highlight styles.</p><articleclass="selection-demo"><h2>Selection highlight</h2><p>This lab changes the colors, decoration, and glow that appear while the user selects text.</p><blockquote>Scoped selection styles are useful in editorial blocks, notes, examples, and branded content areas.</blockquote></article>
Tailwind CSS
Copy Tailwind
Some classes with arbitrary values can be replaced by native classes, depending on the value and your Tailwind CSS configuration.
<p>Select any fragment in the article to review the generated highlight styles.</p><articleclass="selection:bg-[#c7d2fe] selection:text-[#18122b] selection:underline selection:text-shadow-[0_0_4px_#7c3aed]"><h2>Selection highlight</h2><p>This lab changes the colors, decoration, and glow that appear while the user selects text.</p><blockquote>Scoped selection styles are useful in editorial blocks, notes, examples, and branded content areas.</blockquote></article>