Aug 25th, 2022

How to change text selection color in CSS

Author Picture

Dhairya Shah

Software Engineer

By default, text selection comes with light blue background and black text. We are going to change, the text selection color like this: Text selection

In your CSS file,

/* Custom Component Text Selection Change */
    background-color: #FEF4B9;

/* Global Text Selection Change */
::selection {
    background-color: #FEF4B9;

After applying the above code in your CSS file, the text selection color will be changed.

Check out different styles you can apply with text selection:

See the Pen by Dhairya Shah (@dhairyathedev) on CodePen.

Thanks for reading

Follow me on Twitter

Thanks for reading!