Lesson 70 +5 XP

HTML Color Reference

HTML Color Reference

Colors can be written four ways in HTML and CSS: names, RGB, HEX, and HSL. Here is everything you need.

The four ways to write a color

/* 1. Color name */
color: tomato;

/* 2. RGB (red, green, blue, 0-255) */
color: rgb(255, 99, 71);

/* 3. HEX (#rrggbb) */
color: #ff6347;

/* 4. HSL (hue, saturation, lightness) */
color: hsl(9, 100%, 64%);

Add a for transparency: rgba(255, 99, 71, 0.5), #ff634780, hsla(9, 100%, 64%, 0.5).

The 16 basic color names

NameHEXNameHEX
black#000000white#ffffff
red#ff0000yellow#ffff00
blue#0000fflime#00ff00
green#008000orange#ffa500
purple#800080pink#ffc0cb
gray#808080silver#c0c0c0
maroon#800000olive#808000
navy#000080teal#008080

All 148 named colors

Here is every named color recognized by modern browsers, grouped by color family. A few come in two spellings (like gray/grey and aqua/cyan): they are the exact same color!

Reds and pinks

ColorHEXColorHEX
indianred#cd5c5clightcoral#f08080
salmon#fa8072darksalmon#e9967a
lightsalmon#ffa07acrimson#dc143c
firebrick#b22222darkred#8b0000
red#ff0000pink#ffc0cb
lightpink#ffb6c1hotpink#ff69b4
deeppink#ff1493palevioletred#db7093
mediumvioletred#c71585rosybrown#bc8f8f
brown#a52a2amaroon#800000

Oranges and browns

ColorHEXColorHEX
orangered#ff4500darkorange#ff8c00
coral#ff7f50tomato#ff6347
orange#ffa500gold#ffd700
goldenrod#daa520darkgoldenrod#b8860b
chocolate#d2691esaddlebrown#8b4513
sienna#a0522dperu#cd853f
sandybrown#f4a460burlywood#deb887
tan#d2b48cbeige#f5f5dc

Yellows

ColorHEXColorHEX
yellow#ffff00yellowgreen#9acd32
greenyellow#adff2fkhaki#f0e68c
darkkhaki#bdb76bpalegoldenrod#eee8aa
cornsilk#fff8dclemonchiffon#fffacd
lightgoldenrodyellow#fafad2papayawhip#ffefd5
moccasin#ffe4b5peachpuff#ffdab9
bisque#ffe4c4navajowhite#ffdead
wheat#f5deb3lightyellow#ffffe0
ivory#fffff0antiquewhite#faebd7

Greens

ColorHEXColorHEX
green#008000lime#00ff00
limegreen#32cd32chartreuse#7fff00
lawngreen#7cfc00palegreen#98fb98
lightgreen#90ee90springgreen#00ff7f
mediumspringgreen#00fa9amediumseagreen#3cb371
seagreen#2e8b57forestgreen#228b22
darkgreen#006400olivedrab#6b8e23
darkolivegreen#556b2folive#808000
darkseagreen#8fbc8fmediumaquamarine#66cdaa
aquamarine#7fffd4honeydew#f0fff0
mintcream#f5fffa

Cyans and teals

ColorHEXColorHEX
aqua#00ffffcyan#00ffff
darkcyan#008b8blightcyan#e0ffff
paleturquoise#afeeeeturquoise#40e0d0
mediumturquoise#48d1ccdarkturquoise#00ced1
lightseagreen#20b2aacadetblue#5f9ea0
teal#008080

Blues

ColorHEXColorHEX
aliceblue#f0f8ffazure#f0ffff
skyblue#87ceeblightskyblue#87cefa
deepskyblue#00bfffdodgerblue#1e90ff
cornflowerblue#6495edroyalblue#4169e1
mediumblue#0000cddarkblue#00008b
midnightblue#191970steelblue#4682b4
lightsteelblue#b0c4depowderblue#b0e0e6
lightblue#add8e6blue#0000ff
navy#000080

Purples and violets

ColorHEXColorHEX
blueviolet#8a2be2darkviolet#9400d3
darkorchid#9932ccmediumorchid#ba55d3
orchid#da70d6violet#ee82ee
fuchsia#ff00ffmagenta#ff00ff
mediumpurple#9370dbslateblue#6a5acd
darkslateblue#483d8bmediumslateblue#7b68ee
indigo#4b0082rebeccapurple#663399
darkmagenta#8b008bplum#dda0dd
thistle#d8bfd8lavender#e6e6fa
lavenderblush#fff0f5purple#800080

Whites and creams

ColorHEXColorHEX
white#ffffffsnow#fffafa
ghostwhite#f8f8ffwhitesmoke#f5f5f5
seashell#fff5eefloralwhite#fffaf0
oldlace#fdf5e6linen#faf0e6
mistyrose#ffe4e1blanchedalmond#ffebcd

Grays and blacks

ColorHEXColorHEX
black#000000gray#808080
grey#808080gainsboro#dcdcdc
lightgray#d3d3d3lightgrey#d3d3d3
darkgray#a9a9a9darkgrey#a9a9a9
dimgray#696969dimgrey#696969
slategray#708090slategrey#708090
lightslategray#778899lightslategrey#778899
darkslategray#2f4f4fdarkslategrey#2f4f4f
silver#c0c0c0

How RGB works

Every color is a mix of red, green, and blue light. Each from 0 to 255:

  • rgb(255, 0, 0) = pure red
  • rgb(0, 255, 0) = pure green
  • rgb(0, 0, 255) = pure blue
  • rgb(0, 0, 0) = black (no light)
  • rgb(255, 255, 255) = white (all light)
  • rgb(128, 128, 128) = gray (all equal)

How HEX works

A # followed by 6 characters: 2 for red, 2 for green, 2 for blue.

  • ff = the max (255), 00 = zero
  • #ff0000 = red (same as rgb(255,0,0))
  • #00ff00 = green, #0000ff = blue
  • #ffffff = white, #000000 = black
  • Shortcut: #f00 = #ff0000 (repeat each digit)

How HSL works

HSL = Hue, Saturation, Lightness.

  • hue: the base color on a wheel, 0-360 degrees (0 = red, 120 = green, 240 = blue).
  • saturation: how colorful, 0-100% (0% = gray).
  • lightness: how light or dark, 0-100% (0% = black, 100% = white).
color: hsl(0, 100%, 50%);   /* pure red */
color: hsl(120, 50%, 50%);  /* medium green */
color: hsl(240, 100%, 50%); /* pure blue */

Use a color picker!

You don't need to memorize codes. Use a color picker tool (most code editors have one built in), or pick from your browser's dev tools. That's what real developers do!

TL;DR

  • 4 ways: names, rgb(), #hex, hsl().
  • 140 named colors; the 16 basic ones are the classics.
  • Add a for transparency.
  • Use a color picker, not your memory!