According to the W3C
documentation on color units , the numeric values RGB
are represented by hexadecimal notation, preceded by the character #
.
They can contain 3
or 6
digits, being represented as follows:
EM { color: #f00 } /* #rgb */
EM { color: #ff0000 } /* #rrggbb */
What happens when you use only three digits is the replication of them in the rrggbb
formula, so the #fb0
value has its characters replicated and expanded to #ffbb00
.
OBS : There are those who think that the three-digit value is filled with zeros to complete the value hexadecimal
of six digits, and this is a big misconception!
@edit
How would I translate this 3-digit hexadecimal color into 6-digit color?
As explained above, simply replicate the characters, for example: fb0
becomes: ff
, bb
and 00
respectively, forming code: ffbb00
.
Do you have any formula for turning hexadecimal color from 3 to 6?
There is no specific formula for this "schema", the browser itself takes care of replication, but if it is for a specific use case, you can implement replication the way you want.