Is this how html colors work? I'm trying to figure out how to pick my hexadecimal codes. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Is this how html colors work? I'm trying to figure out how to pick my hexadecimal codes.

There are 6 characters that are split by 2s, so the first 2 digits are red, digits 3 and 4 are green, and digits 5 and 6 are blue. That's easy and I get that much, but what I want to know is do I multiply the 2 digits of a color type to get its value out of 256? My reason for thinking this is because hexadecimal is base 16 and we have 2 digits meaning at a maximum we can theoretically have 256 = 16 Ɨ 16. The giant obvious problem with this is that the largest value in base 16 is 15, so our max would be 225.

21st Apr 2017, 8:08 PM
Cosmo Nibbs
Cosmo Nibbs - avatar
3 Respostas
+ 6
You have digits from 0 to F at your disposal. If you split the six-digit value into color-related, you have 00..FF for each color. F means 15 alright, but hexadecimal means that the right digit relates to 16**0, so 1, while the left one relates to 16**1, so 16. And so FF is 15*(16**0)+15*(16**1)=15+240=255. This is why it's translated as 0-255 in base10. BTW, in base10 you have 9 as the highest digit, but that doesn't mean you have only 81 combinations, right? ;)
21st Apr 2017, 8:52 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
Just use ="#color" I think this is OK
21st Apr 2017, 8:44 PM
Ahmad Jafar Muhammad
Ahmad Jafar Muhammad  - avatar
0
Its a two digit hexadecimal number! That makes much more sense! Thank you!
21st Apr 2017, 9:15 PM
Cosmo Nibbs
Cosmo Nibbs - avatar