A HEX color starts with # followed by six characters. The characters are hexadecimal digits: 0-9 and a-f.
color: #d94a00;
How to read it
The six digits are three pairs: RR GG BB, which means red, green and blue. Each pair is a number from 00 (none of that color) to ff (the most).
| HEX | Red | Green | Blue | Result |
|---|---|---|---|---|
#ff0000 | full | none | none | Pure red |
#00ff00 | none | full | none | Pure green |
#000000 | none | none | none | Black |
#ffffff | full | full | full | White |
#d94a00 | a lot | some | none | Burnt orange |
Try it
<style>
div { padding: 10px; margin-bottom: 6px; color: white; }
</style>
<div style="background:#d94a00">#d94a00</div>
<div style="background:#1a5276">#1a5276</div>
<div style="background:#27ae60">#27ae60</div>
<div style="background:#333">#333 (short form)</div>
Shortcuts
- Short form: if each pair has two identical digits, you can write one:
#ffcc00is#fc0, and#333333is#333. - With transparency: add two more digits at the end:
#d94a0080is the same orange at about 50% opacity. The last pair is the alpha.
Hex codes are not case-sensitive, so #D94A00 and #d94a00 are identical.
You do not need to calculate them
Missing the hash
color: d94a00; is invalid. The # is part of the value.