frenchie
frenchie

Reputation: 52047

changing user selection color

I hate it when I'm browsing and end up selecting text or elements on a webpage by accident; everything turns blue! So for the moment, I'm using this class on the parts of the page where the user could mistakenly select things:

.NoSelect{
    -webkit-user-select:none;
    -moz-user-select:none;
    -ms-user-select:none;}

This works fine but the problem is that I end up with lots of divs that have this class.

Is there a way to change the color of selected text and selected elements and make it transparent?

Thanks.

Upvotes: 0

Views: 267

Answers (1)

Jason
Jason

Reputation: 52547

You can use the ::selection CSS attribute.

for everything:

::selection { background: transparent; }

or just p tags, for example:

p::selection { background: transparent; }

Here's an example.

Upvotes: 3

Related Questions