Skip to main content

Command Palette

Search for a command to run...

How to change text selection color in CSS

Published
•1 min read
How to change text selection color in CSS
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

By default, text selection comes with light blue background and black text. We are going to change, the text selection color like this: Screenshot 2022-08-25 at 1.35.15 PM.png

In your CSS file,

/* Custom Component Text Selection Change */
.component::selection{
    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:

Thanks for reading

Follow me on Twitter

Thanks for reading!

8 views

More from this blog

D

Dhairya Shah

119 posts