{"id":14668,"date":"2015-05-22T05:01:14","date_gmt":"2015-05-21T19:01:14","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=14668"},"modified":"2015-05-21T21:33:30","modified_gmt":"2015-05-21T11:33:30","slug":"htmljavascript-colour-name-translation-into-rgb-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascript-colour-name-translation-into-rgb-tutorial\/","title":{"rendered":"HTML\/Javascript Colour Name Translation into RGB Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/colour_translation.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"HTML\/Javascript Colour Name Translation into RGB Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/colour_translation.jpg\" title=\"HTML\/Javascript Colour Name Translation into RGB Tutorial\"  \/><\/a><p class=\"wp-caption-text\">HTML\/Javascript Colour Name Translation into RGB Tutorial<\/p><\/div>\n<p>Sometimes you know a colour by a name, and perhaps that name is recognised as an RGB type of colour.  Today we write some HTML and Javascript code, which, admittedly, does not work for all the web browsers (notably (not) Firefox) but will work in Safari or Google Chrome or Opera to tell you this web analysis of a colour name&#8217;s RGB makeup.<\/p>\n<p>This brings into play the 16 default web colours (you can read about here at <a target=_blank title='Web colours information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Web_colors'>Wikipedia<\/a> &#8230; thanks) namely &#8230;<\/p>\n<table style=\"padding:2px;\" class=\"wikitable sortable jquery-tablesorter\">\n<caption>CSS 1&ndash;2.0 \/ HTML 3.2&ndash;4 \/ VGA color names<\/caption>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Hex<\/a> <small>(RGB)<\/small><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th style=\"border-left:solid 4em rgb(255,255,255); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"White\" href=\"\/wiki\/White\">White<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#FFFFFF<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(192,192,192); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Silver (color)\" href=\"\/wiki\/Silver_(color)\">Silver<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#C0C0C0<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(128,128,128); text-align:left; font-weight:normal; text-transform: capitalize;\"><a class=\"mw-redirect\" title=\"Gray\" href=\"\/wiki\/Gray\">Gray<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#808080<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,0,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Black\" href=\"\/wiki\/Black\">Black<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#000000<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(255,0,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Red\" href=\"\/wiki\/Red\">Red<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#FF0000<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(128,0,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a class=\"mw-redirect\" title=\"Maroon (color)\" href=\"\/wiki\/Maroon_(color)\">Maroon<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#800000<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(255,255,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Yellow\" href=\"\/wiki\/Yellow\">Yellow<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#FFFF00<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(128,128,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Olive (color)\" href=\"\/wiki\/Olive_(color)\">Olive<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#808000<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,255,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Lime (color)\" href=\"\/wiki\/Lime_(color)\">Lime<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#00FF00<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,128,0); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Green\" href=\"\/wiki\/Green\">Green<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#008000<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,255,255); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Aqua (color)\" href=\"\/wiki\/Aqua_(color)\">Aqua<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#00FFFF<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,128,128); text-align:left; font-weight:normal; text-transform: capitalize;\"><a class=\"mw-redirect\" title=\"Teal (color)\" href=\"\/wiki\/Teal_(color)\">Teal<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#008080<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,0,255); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Blue\" href=\"\/wiki\/Blue\">Blue<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#0000FF<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(0,0,128); text-align:left; font-weight:normal; text-transform: capitalize;\"><a class=\"mw-redirect\" title=\"Navy blue (color)\" href=\"\/wiki\/Navy_blue_(color)\">Navy<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#000080<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(255,0,255); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Fuchsia (color)\" href=\"\/wiki\/Fuchsia_(color)\">Fuchsia<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#FF00FF<\/td>\n<\/tr>\n<tr>\n<th style=\"border-left:solid 4em rgb(128,0,128); text-align:left; font-weight:normal; text-transform: capitalize;\"><a title=\"Purple\" href=\"\/wiki\/Purple\">Purple<\/a><\/th>\n<td style=\"border-left:solid 2px #AAA;border-right:solid 1px #AAA;font-family:monospace;\">#800080<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8230; because the method to translate these 16 default colours needs to be separated into a separate (mapping) lookup piece of logic, rather than letting the web browser (and Javascript DOM) do the work.<\/p>\n<p>So please feel free to download the HTML and Javascript code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/colour_translation.html_GETME\" title='colour_translation.html'>colour_translation.html<\/a> or try the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/colour_translation.html\" title='Click picture'>live run<\/a>, and see you round &#8230; like a rissole (<font size=1>chortle &#8230; chortle<\/font>).<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d14668' onclick='var dv=document.getElementById(\"d14668\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=Javascript\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d14668' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you know a colour by a name, and perhaps that name is recognised as an RGB type of colour. Today we write some HTML and Javascript code, which, admittedly, does not work for all the web browsers (notably (not) &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/htmljavascript-colour-name-translation-into-rgb-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[224,275,576,652,997,1065,1301,1319],"class_list":["post-14668","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-colour","tag-cross-browser","tag-html","tag-javascript","tag-programming","tag-rgb","tag-translation","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14668"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=14668"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14668\/revisions"}],"predecessor-version":[{"id":14675,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14668\/revisions\/14675"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=14668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=14668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=14668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}