Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting different colors in different browsers using the same hexadecimal value? [duplicate]

Tags:

html

css

I set the selection color in my css file, using a hexadecimal value. The thing is, Firefox and Chrome do not render the same color out of this.

Do I need to specify something to make the code render the same?

I tried using the -webkit- and got nothing out of it. The hexadecimal value is the exact same I used for the text color. Everything, from rendering color to JS animations works perfectly with Firefox and IE, but Chrome does weird things.

On Chrome:

Chrome

On Firefox:

On Firefox

::selection {
  background: #f997f1;
}

::-webkit-selection {
  background: #f997f1;
}

::-moz-selection {
  background: #f997f1;
}

body {
  background: lightblue;
}

p {
  font-family: sans-serif;
  font-size: 2em;
  color: #f997f1;
}
<p>Some text to select</p>

1 Answers

I can reproduce it in Chrome. It looks like it is because the selection is not completely opaque. If you set a background picture, you can see it shine through. This also means that the blue background color shines through, affecting the overall color of the selection.

I cannot (yet) find what exactly causes this and how to change it. Opacity doesn't work. The color is normal rgb... Anyway, proof of the cause can be seen here.

::selection {
  background: #f997f1;
}

::-webkit-selection {
  background: #f997f1;
}

::-moz-selection {
  background: #f997f1;
}

body {
  background: lightblue;
  background-image: url(https://www.google.nl/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png)
}

p {
  font-family: sans-serif;
  font-size: 2em;
  color: #f997f1;
}
<p>Some text to select</p>
like image 98
GolezTrol Avatar answered Oct 22 '25 04:10

GolezTrol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!