Why does HTML think “chucknorris” is a Color? How come certain random strings produce colors when entered as background colors in HTML? For example: <body bgcolor="chucknorris"> test </body> ...produces a document with a red background across all browsers and platforms. Interestingly, while chucknorri produces a red background as well, chucknorr produces a yellow background. What's going on here? Answer : It's a holdover from the Netscape days: Missing digits are treated as 0[...]. An incorrect digit is simply interpreted as 0. For example the values
undefined
CSS background color in JavaScript How can I set the CSS background color of an HTML element using JavaScript? Answer : In general, CSS properties are converted to JavaScript by making them camelCase without any dashes. So background-color becomes backgroundColor. function setColor(element, color) { element.style.backgroundColor = color; } source : http://stackoverflow.com/questions/3319/css-background-color-in-javascript