Hex Codes
Hexadecimal (or hex) values, are written as a single string, prepended with a number sign, with digits for each color. #RRGGBB
CSS
/* Black as a hex code: */
p {
color: #000000;
}
The major difference is that you can represent 256 values with a two-bit hexadecimal number. In hexadecimal numbering, each digit has 16 values (0-f). And, 16 * 16 = 256.
If we were translate this to binary:
Binary | Hex |
---|---|
0 | 0 |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
10 | a |
11 | b |
12 | c |
13 | d |
14 | e |
15 | f |
So, in hex, we write the value: |
---|
000 as 00 |
010 as 0a |
015 as 0f |
016 as 10 |
017 as 11 |
031 as 1f |
032 as 20 |
050 as 32 |
100 as 64 |
150 as 96 |
200 as c8 |
250 as fa |
255 as ff |
- Previous
- Next