|
|
|
|
|
by williamdclt
357 days ago
|
|
This is hexadecimal notation for rgb. Each character represents 2 bytes, which encode a value from 0 to 255. This is a bit more confusing because this is a shorthand notation: you’d actually need 2 hexadecimal characters for 2 bytes (eg #0077ff would be rbg(0, 127, 255)). In this shorthand notation, I think there’s an implied 0 (eg #07f is #0070f0). So you can’t represent all rgb colour with only 3 characters, but for this use-case it’s fine. In css you can use either of these 3 notations, for example |
|
From <https://www.w3.org/TR/CSS1/>:
> The format of an RGB value in hexadecimal notation is a '#' immediately followed by either three or six hexadecimal characters. The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00. This makes sure that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display.
I'm quite fond of the 3-digit hexadecmial RGB notation. It's a concise way to express the colours I use for web pages or Emacs font locking. In these cases, I rarely need the full 16-million-colour range offered by 6 digits. The 3 digits are usually more than enough, at least to me.