RGB to Hex Calculator - A JavaScript App!
The three primary colors of light are red, green and blue. Together, they blend to make all the colors you see on your computer monitor. Their 'tint values' range from 0 to 255 (integers only!, [0, 255]). A couple of guidelines:
- rgb(0,0,0) => black
- rgb(255,255,255) => white
- rgb(x, x, x) => shades of gray
For convenience, they triad is often to converted to a single "hex" code composed of 6 symbols (0-9, A-F). "Hex" is short for "hexadecimal" and is a base-16 number. (See your computer science/math teacher for details). In CSS, that "hex code" is used for coloring elements (for example: html { background-color: #00FF00; }
would give a background color of green to a web page.) A few additional "hex" observations:
- often preceeded by a '#' symbol
- white => #FFFFFF
- black => #000000
- The first two symbols identify red tint; the second pair, green tint; the last pair, blue tint: #RRGGBB
- A shortcut code is often used for duplicate symbols in the tint pairs. For example: #AA99CC => #A9C
This web app was inspired by a page at the site: www.javascripter.net. It was "brought up to code" to HTML5 and whenever possible, the html, CSS and JavaScript (structure, style, behavior) elements were compartmentalized.