Why numbers???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why numbers????

will i am wondering why we use numbers to choose colors while we can use their names????

21st Sep 2018, 6:39 PM
Waleed Alsiyame
Waleed Alsiyame - avatar
4 Answers
+ 2
becayse colors are represented by hexadecimal values that a computer can interpret. computers cannot understand English directly and at some level human readable code is broken down into machine code, that the processor and gpu can process as instructions.
21st Sep 2018, 6:44 PM
John
John - avatar
+ 1
With 32bit exist 2^32 possible colors... You can give a name to all they? 😀
21st Sep 2018, 6:53 PM
KrOW
KrOW - avatar
+ 1
I was wondering if performance could be related* Here's a performance test comparing color names against hex, rgb*() and hsl*() coding: https://jsperf.com/css-color-names-vs-hex-codes/25 "Long hex codes" won the first time I ran it, but every subsequent run "color names" has finished first. * The differences don't seem to be that great between hex and names, but those function-like constructs look like they matter.
21st Sep 2018, 8:00 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
In addition to KrOW's comment about not having names for all possible color values... We use numbers for consistency in expected output. Historically, the list of standardized color names changed (and very likely could change again in the future). https://css-tricks.com/nerds-guide-color-web/ https://en.wikipedia.org/wiki/Web_colors https://css-tricks.com/snippets/css/named-colors-and-hex-equivalents/ One more for luck: https://caniuse.com/#search=rebeccapurple
21st Sep 2018, 8:38 PM
Janning⭐
Janning⭐ - avatar