Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert 3-digit HTML hex colors to 6-digit flex hex colors

I want to convert a three-digit hex color which is coming from HTML CSS to a six-digit hex color for Flex. Can anyone give me code to convert 3-digit hex colors to their 6-digit equivalents?

like image 409
Trinu Avatar asked Apr 19 '12 14:04

Trinu


People also ask

Can hex be 3 digits?

3 Digit HEX ValueThe 3-digit hex code is a shorthand for some 6-digit hex codes. Where r, g, and b represent the red, green, and blue components with values between 0 and f. The 3-digit hex code can only be used when both the values (RR, GG, and BB) are the same for each component.

Are hex codes always 6 digits?

Hex Codes Represent Red, Green and Blue In fact, equal levels of red, green and blue, whatever that level may be, will always produce a shade of gray. The six digits of a hex code are in fact three two-digit numbers, each representing the level of red, green and blue.

What color code is 6 digits?

Hex is a 6-digit, 24 bit, hexidecimal number that represents Red, Green, and Blue.


2 Answers

The three digit hex colors are expanded by doubling each digit (see w3 spec). So #F3A gets expanded to #FF33AA.

like image 143
mrab Avatar answered Sep 27 '22 19:09

mrab


Double every digit: for example #A21 is equal to #AA2211.

However this question is a duplicate of: convert to 3-digit hex color code

like image 44
dash1e Avatar answered Sep 27 '22 19:09

dash1e