Skip to main content

HEX Value

A hexadecimal (hex) color is written as #rrggbb.

Here rr (red), gg (green), and bb (blue) are hex values between 00 and ff, which is the same range as 0 to 255 in decimal.

For example, #ff0000 is red, because red is at its highest (ff) and the others are at the lowest (00). Use #000000 for black and #ffffff for white.

HEX colors

Six colors written as 6-digit hex values.

Prompt
An HTML page showing several colors written as 6-digit hex values. Make six headings with background colors: #ff0000, #0000ff, #3cb371, #ee82ee, #ffa500, and #6a5acd. Label each with its hex value.
Output: complete HTML page

Shades of gray

Shades of gray are made when the red, green, and blue pairs are equal.

Prompt
An HTML page showing shades of gray made with equal hex pairs for red, green, and blue. Make six headings with background colors: #3c3c3c, #616161, #787878, #b4b4b4, #f0f0f0, and #f9f9f9. Label each.
Output: complete HTML page

3 Digit HEX Value

Sometimes you will see a 3-digit hex code, written as #rgb. It is a shorthand for some 6-digit codes.

It can only be used when both digits of each pair are the same. So #ff00cc can be shortened to #f0c.

Example

Each 3-digit code stands for its matching 6-digit code.

Prompt
An HTML page that uses 3-digit hex shorthand in an internal style block. Set the body background to #fc9 (same as #ffcc99), the <h1> color to #f0f (same as #ff00ff), and the <p> color to #b58 (same as #bb5588). Add a heading and a paragraph.
Output: complete HTML page