According to the documentation of W3C
about color units, the numerical values RGB
are represented by hexadecimal notation, preceded by the character #
.
They may contain 3
or 6
digits, being represented as follows:
EM { color: #f00 } /* #rgb */
EM { color: #ff0000 } /* #rrggbb */
What happens when you only use three digits is their replication in the formula rrggbb
, therefore, the value #fb0
has its characters replicated and expanded to #ffbb00
.
OBS: Some think that the value of three digits are filled with zeros to complete the value hexadecimal
six-digit, and this is a big misunderstanding!
@Edit
How would I translate this 3-digit hexadecimal color into the 6-digit?
As explained above, just replicate the characters, for example: fb0
becomes: ff
, bb
and 00
respectively, forming the code: ffbb00
.
Has some formula to turn color hexadecimal from 3 to 6?
There is no specific formula for this "scheme", the browser itself takes care of the replication, but if it is for a specific use case, you can implement the replication however you want.
I think this can help you : https://www.w3.org/TR/2001/WD-css3-color-20010305#colorunits
– Roknauta