0

In order to perform the conversion I followed a Stack Overflow post below which gave an idea how the conversions are taking place and colors are shown by browser

But when I checked with following examples:

<body bgcolor="a">
10,0,0
#0A 00 00


<body bgcolor="marker">
10,0,224
#0A 00 E0


<body bgcolor="kevineve">
224,14,224
#E00EE0

Same rule did not help me find the exact values for kevineve #E00EE0

What are the rules to convert a color name to its hex value ?

Color name can be any value: like below post or just any alphabet

Stack Overflow post: Why does HTML think “chucknorris” is a color?

Note: please note hex converted values of: a and kevineve

dippas
  • 58,591
  • 15
  • 114
  • 126
Tharif
  • 13,794
  • 9
  • 55
  • 77
  • I think your answer is [here](http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes). Similar question. – WP Learner Feb 02 '16 at 11:30
  • @user2584538 no its not similar here no real color names are taken into account – Tharif Feb 02 '16 at 11:32
  • you can use a DB storage or array like something. isn't that possible for you..? – WP Learner Feb 02 '16 at 11:37
  • we cannot store every value in db know..Color name can be any value : SO post mentioned or just any alphabet – Tharif Feb 02 '16 at 11:40
  • 1
    @utility: You may want to check this out -- http://randomstringtocsscolor.com/ and the complete set of rules from the HTML5 specs are here - https://www.w3.org/TR/2011/WD-html5-20110525/common-microsyntaxes.html#colors – Abhitalks Feb 02 '16 at 11:41
  • @Abhitalks cannot load that site .. is that site live ? – Tharif Feb 02 '16 at 11:43
  • @utility Try this http://stackoverflow.com/questions/2553566/how-to-convert-a-string-color-to-its-hex-code-or-rgb-value – WP Learner Feb 02 '16 at 11:43
  • @utility: Yes. Just checked. – Abhitalks Feb 02 '16 at 11:43
  • thank you @Abhitalks , it seems there is an algorithm for the same at : https://www.w3.org/TR/2011/WD-html5-20110525/common-microsyntaxes.html#colors ..let me work out the same – Tharif Feb 02 '16 at 11:46
  • Possible duplicate of [Why does HTML think “chucknorris” is a color?](http://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color) – dippas Feb 02 '16 at 11:52
  • @dippas no post is not a duplicate one , that particular post focused on a particular word – Tharif Feb 02 '16 at 11:56
  • your kevineve is well converted to rgb and hex. – dippas Feb 02 '16 at 11:58
  • @dippas but the hex value is different from that stated in that SO post know – Tharif Feb 02 '16 at 11:59
  • @utility see my answer – dippas Feb 02 '16 at 12:21

0 Answers0