HTML Color Codes

Copy common HTML color codes and learn how HEX, RGB, HSL and named colors map to CSS.

Basic HTML colors

Black
rgb(0, 0, 0)
White
rgb(255, 255, 255)
Red
rgb(255, 0, 0)
Green
rgb(0, 128, 0)
Blue
rgb(0, 0, 255)
Yellow
rgb(255, 255, 0)
Cyan
rgb(0, 255, 255)
Magenta
rgb(255, 0, 255)
Silver
rgb(192, 192, 192)
Gray
rgb(128, 128, 128)
Maroon
rgb(128, 0, 0)
Olive
rgb(128, 128, 0)

Popular modern colors

HTML color code formats

Modern HTML and CSS accept several color formats: HEX values such as #4F46E5, RGB functions such as rgb(79, 70, 229), HSL functions such as hsl(243, 75%, 59%), and named colors such as royalblue.

Frequently asked questions

What is an HTML color code?+

An HTML color code is any CSS color value used to style HTML elements, most commonly HEX, RGB, HSL or a named color.

Should I use HEX or RGB?+

Use HEX for compact static colors and RGB or HSL when you need alpha, calculations or easier design-token manipulation.

Can I use 3-digit HEX codes?+

Yes. A 3-digit HEX code is shorthand: #F0A expands to #FF00AA.

Related tools