LT86
LT86

Reputation: 655

Why does *::selection not give you the correct colour?

I have Googled this but can't find any info on it.

Say you set your page highlight colour to a nice orange:

*::selection {
     background: #C44610;
 }

Why, when you highlight your page, does the background show as red, I swabbed this colour in photoshop and it gives me a hex value of #c24432 which is way off the orange I selected.

I have tested this on Chrome. In firefox I can't get the selection to work at all, it just gives me the default colour.

Any thoughts?

Upvotes: 0

Views: 63

Answers (2)

DeiForm
DeiForm

Reputation: 664

For example you can edit this code:

::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }

Upvotes: 2

Santiago Baigorria
Santiago Baigorria

Reputation: 696

Don't need the *

Also will need the ::-moz-selection {} for Firefox

BTW, you shoulkd consider that since the selection color is a bit transparent, it changes depending on the background...

Greetings from Argentina

Upvotes: 1

Related Questions