1

Shouldn't it be some sort of grey? But both FireFox and Chrome shows it like pink. When I entered that value in Paint.NET it looked grey. Why does #ff7f7f7f look pink on web browsers?

enter image description here

enter image description here

<html><body>
<h1 style="background: #ff7f7f7f">Why does #ff7f7f7f look like this?</h1>
</body></html>
Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135
  • Odd as it sounds, I believe your question is answered here: [Why does HTML think “chucknorris” is a color?](https://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color) – IMSoP Jun 06 '20 at 21:35
  • Is it showing as a pink color anywhere else? Is this even programming related? – Vepth Jun 06 '20 at 21:37
  • 1
    You've mixed up the order with alpha channel. It's not ARGB, it's RGBA. – Brad Jun 06 '20 at 21:41
  • @IMSoP No, I don't think that answers this. That is about ignoring invalid characters in the colour hexadecimal string, but this was about the order of colour components. – Damn Vegetables Jun 06 '20 at 21:52
  • @DamnVegetables The answers also discuss how colours which aren't multiples of 3 in length are handled; I wasn't aware that some browsers now handle 4 and 8 character strings as RGBA instead of applying that algorithm. – IMSoP Jun 07 '20 at 12:09

2 Answers2

5

#ff7f7f7f corresponding to #rrggbbaa notation which is RED-GREEN-BLUE-ALPHA values, two hex characters for each value. The color is the pink you are getting.

I guess copying into Paint.NET just trims the first two characters because it expecting only #rrggbb notation, trimming it into #7f7f7f which is gray. (But i'm not familier how Paint.NET works :) )

rid
  • 61,078
  • 31
  • 152
  • 193
SomoKRoceS
  • 2,934
  • 2
  • 19
  • 30
  • 1
    Indeed, `ff7f7f` is a dark pink, but with `7f` opacity it becomes lighter. – rid Jun 06 '20 at 21:45
  • 1
    Yeah, the data source used ARGB hexadeximal format like #AARRGGBB, and somehow I just assumed that HTML/CSS would also use ARGB format. After some web research, it seems they use RGBA. I tried to mark this as the answer, but it seems I have to wait. – Damn Vegetables Jun 06 '20 at 21:46
  • I might be wrong, but my impression from the "chucknorris" question linked above is that hex colours are always interpreted as RGB, not RGBA. – IMSoP Jun 06 '20 at 21:52
  • @IMSoP some browser's versions supports it: https://caniuse.com/#feat=css-rrggbbaa – SomoKRoceS Jun 06 '20 at 21:54
  • 1
    @SomoKRoceS Ah, I didn't know that; I guess the linked question predates that, which is why the answers talk about finding the nearest multiple of three. I wonder if chucknorris has changed colour as a result. :) – IMSoP Jun 07 '20 at 12:14
  • @IMSoP that's an interesting question :P I'm not sure if the default notation is #rrggbb or #rrggbbaa (I think it's still #rrggbb and only if the value is 8 characters long it is considered as #rrggbbaa but I didn't verified it). – SomoKRoceS Jun 07 '20 at 12:24
1

If you inspect the element with the browser's dev tools you can check the computed style and you'll see it's parsed as an rgba color (rgba(255, 127, 127, 0.498))

EDIT: note that the color picker software you are using is not picking the color of the div but the color of the screen pixel (which is some pink color with ~0.5 alpha with white behind, that's why you get that weird FFBFBF color there)

arieljuod
  • 15,460
  • 2
  • 25
  • 36