David Novak David Novak - 4 months ago 9
CSS Question

Web colors hexadecimal notation

Usually colors in hexadecimal notation are presented with a hashtag following 6 hexadecimal characters. What color does the value #AAA produce? Are the other characters derived from the existing ones? Are the missing values just assumed?

Answer

Nice question.

Short answer: #xyz is read as #xxyyzz, so the specific example means #aaa becomes #aaaaaa, a gray quite dark tone (68.75%).

Wikipedia calls this shorthand hex form, https://en.wikipedia.org/wiki/Web_colors#Shorthand_hexadecimal_form

CSS does have a formal specification, but it is a very long read. To experiment with the specific colors that CSS allows, maybe browser debuggers is good. jsfiddle is also a possibility: http://jsfiddle.net/mYdb5/ which contains the following simple code:

Color test:<br/>
<div/>

div {
    background-color: #aaa;
    width:100%;
    height:40px;
}
Comments