0
.background-red {
    background-color: #ff6767d4;
}

On Microsoft Edge (not the Chromium one), this color is not being rendered correctly. How can I use CSS to use the following IF it's Edge

.background-red {
    background-color: red;
}
software is fun
  • 7,286
  • 18
  • 71
  • 129
  • 2
    Hex is 6 symbols, not 8 – Justinas Sep 23 '20 at 13:34
  • 3
    Hex with 8 Symbols is also valid syntax, it specifies opacity with the last 2 values. – cloned Sep 23 '20 at 13:36
  • @cloned You can even use `color: #TFUBLYN`, but if your browser is not supporting wrong values, then it will simply ignore whole rule. – Justinas Sep 23 '20 at 13:37
  • @cloned Just tested, you are correct. Could come in useful, cheers. – SJacks Sep 23 '20 at 13:41
  • To see all the possibles way to define a color and the browser's support of them : https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Browser_compatibility – SeeoX Sep 23 '20 at 13:46

2 Answers2

3

You just write:

.background-red {
    background-color: red;
    background-color: #ff6767d4;
}

The last working value will be used. If a browser doesn't understand a value it will fall back to the last one that it understands.

Edit: You can also use rgba() to define your color, as far as I know edge supports this format.

cloned
  • 6,346
  • 4
  • 26
  • 38
1

Based on this answer and caniuseit table IE does not support hex value with alpha channel. That's why it's ignoring whole rule.

To apply non valid values, you must set fallback for it. Note the order - browser will use last known rule when encountering invalid value.

.background-red {
    background-color: rgba(255, 103, 103, .83);
    background-color: #ff6767d4;
}

Justinas
  • 41,402
  • 5
  • 66
  • 96