How to create a hex color? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

How to create a hex color?

I don't know how to mix numbers with letters to make a specific color. Can someone explain this to me?

1st Jun 2017, 6:48 PM
DeltaTick
DeltaTick - avatar
6 Answers
+ 12
Hex colors are constructed as #RRGGBB, where RR, GG and BB are shades of red, green and blue, respectively. Shades can be of a scale from 0 to 255, where 0 is none and 255 is max. Those are always two-digit numbers, you simply write those numbers using hexadecimal (base16) notation, instead of decimal (base10) notation. So #00 represents decimal zero, while #FF represents decimal 255. First digit from the right is a hexadecimal digit of units, while the second from the right is a number of sixteens. Examples: #30 ==> 0 * 16^0 + 3 * 16^1 = 48 #AE ==> 14 * 16^0 + 10 * 16^1 = 14*1 + 10*16 = 174 #FF ==> 15 * 16^0 + 15 * 16^1 = 15 + 240 = 255
1st Jun 2017, 6:56 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
each two digits represent one color. # 00 00 00 red green blue it goes from 0 to 9, than instead of 10, we have A. instead of 11, we have B. so the complete range of each single value in hexadecilmal is 0,1,2,3 4,5 6 7 8,9,A,B,C,D,E,F. as hex colors use two digits for each colour, the minimum is 00(black), and the maximum FF(white). #000000 <~ no values for red green and blue, results black #FF0000 <~ maximum value of red, no green and no blue, red color #0000FF <~ maximum value of blue, no red and no green. blue color #FFFF00 <~ all red, all green and no blue. Results in yellow color. This is the logic, but it's too hard to guess all shades you want just by yourself. So what you can do is try to guess and memorize simple shades. As it's too hard to memorize all the colors you need and would waste your time too, that's why we have color pickers, as the one i created here: https://code.sololearn.com/W3CMecJLcM18/?ref=app
1st Jun 2017, 7:02 PM
Welliton Malta
Welliton Malta - avatar
+ 2
just search this on google --- hex color codes --- U will be directed to a website where u can find hex color codes
1st Jun 2017, 6:55 PM
_Retr0/-
_Retr0/- - avatar
+ 2
'numbers and letters' are hexadecimal digits: 0,1,2,3,4,5,6,7,8,9, and: A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 decimal system uses decimal digits (0,1,2,3,4,5,6,7,8,9) in decimal system: 124 = 1*10^2 + 2*10^1 + 4*10^0 = 1*100 + 2*10 + 4*1 hex number consists of hex digits for example A4E: A*16^2 + 4*16^1 + E*16^0 = 10*256 + 4*16 + 14*1 = 2638 typical color coding is: RRGGBB where RR, GG, BB is two hex digital value (from 00 to FF) 00 hex is 0 dec 3E hex is 62 dec FF hex is 255 dec 'every' color can be represented by 3 components: red, green, blue (this is RGB color model, there are also other models of color like HSL, HSV..) RR is value of RED component GG is value of GREEN BB is value of BLUE when you see #FF0000 - it is red color (full red, no green, no blue) # - means hexadecimal value #008000 is green (darker than #00FF00 because 80 is half of FF) #FFFFFF is white (all R,G,B are present) #000000 is black (none of R,G,B is present) #808080 is gray (the same values of R G B -> it's always gray, from black to white) yellow is red + green -> #FFFF00 (no blue) sometimes you can see #RGB (three digits instead of six), it is shorter notation (less colors): #400 = #440000 #0E3 = #00EE33
1st Jun 2017, 7:24 PM
Michal
Michal - avatar
+ 1
not exactly hex color r not actually created by u but u actually tell the browser to use this shade of color
1st Jun 2017, 6:57 PM
_Retr0/-
_Retr0/- - avatar
0
Here is an android app I wrote to handle this. http://leakyegg.website.tk/RGB.apk Here is the PC version I wrote. http://leakyegg.website.tk/RGB.zip By all means, take them. I used the android version to get the browns and yellow for this https://code.sololearn.com/WS1m4CzAltQI/?ref=app
1st Jun 2017, 7:31 PM
LordHill
LordHill - avatar