Kanbritech Learn logo
HTML HTML Tutorial 45h track

HEX

Expand #abc into six digits and write the hex value for pure red.

Understand the topic

Hexadecimal colors encode RGB channels using base-16 digits: 0 through 9 and a through f. A six-digit value contains two digits for each channel. #000000 is black and #ffffff is white. Three-digit shorthand repeats each digit, so #369 expands to #336699. An eight-digit value adds an alpha channel at the end.

Worked example

<p style="color: #336699; background: #eef6ff;">Hexadecimal colors</p>

The first pair, 33, describes red; 66 describes green; and 99 describes blue. Hex values are case-insensitive.

Practice

Expand #abc into six digits and write the hex value for pure red.

Show a suggested answer
#abc becomes #aabbcc
pure red is #ff0000

Common mistake

A hex color needs the leading # in CSS. Without it, the value is not interpreted as a hex color.

HTML documentation

Live Example

Try Coding

Result