designwithfocus

Color codes & color models

Purple Color Code: HEX, RGB, CMYK and HSL

By Design With Focus Team 7 min read
A row of purple swatches from indigo through lavender on a white field

Short answer

The purple color code is #800080, which is rgb(128, 0, 128) in the CSS named-color table. Computed from that sRGB value, HSL is 300 degrees, 100% saturation, and 25% lightness, and CMYK is 0, 100, 0, 50. You can type the keyword purple and get the same sRGB color. The shade table uses other names printed in that W3C list, not invented labels.

Last verified against the sources listed below.

Key takeaways

  • CSS Color Level 4 lists purple as #800080, decimal 128 0 128, one of the 16 colors that came from the VGA palette.
  • Rebecca purple is #663399. Indigo is #4B0082. Violet is #EE82EE. Those hex values are in the same named-color table.
  • HSL and CMYK in the table are computed from the sRGB value. The W3C table prints hex and decimal RGB, not HSL or CMYK.
  • Contrast ratios are computed with the WCAG 2.2 relative-luminance formula. Purple on white is 9.42:1.
  • WCAG 2.2 asks for at least 4.5:1 for normal text at level AA, 3:1 for large text, and 7:1 for normal text at AAA.
  • Fuchsia and magenta are both #FF00FF in the named-color table. They are not the keyword purple.

The purple color code in CSS is a named color, not a single paint chip from a brand book. CSS Color Module Level 4 resolves the keyword purple to an sRGB value, and the same table lists the other purples below. Hex and decimal RGB come from that table. HSL, CMYK, and contrast on this page are computed.

The editor’s draft at the CSS Working Group prints the same purple hex and the same decimal RGB. MDN’s named-color page is the stylesheet reference for writing the keyword. Mixing purple from pigments is a different question, covered in what colors make purple.

What is the purple color code?

The purple color code is #800080, or rgb(128, 0, 128). The named-color table prints that hex in lowercase and the decimal as 128 0 128.

In a style sheet you can write the keyword purple, the hex, or the rgb() function. CSS Color Level 4 says the names resolve to sRGB and that the keywords are ASCII case-insensitive. The Purple Color Code tool copies those hex values in the browser.

Computed from the sRGB value, HSL is hsl(300, 100%, 25%) and CMYK is 0% cyan, 100% magenta, 0% yellow, 50% black. Those two forms are not columns in the W3C table. They are the usual conversions from the RGB the table does print. A press profile can shift the CMYK result.

Where do the HEX values come from?

They come from the named-color table in CSS Color Level 4, section 6.1. This page does not add names that table does not contain.

The spec says sixteen names, including purple, came from the VGA palette and then HTML. Most of the rest came from an X11 color set and then SVG. It also says the names are standardized because implementations already used them, not because each name is evenly spaced.

RGB is the model those decimal columns use: three channels from 0 to 255. Purple’s red and blue channels are 128 and its green channel is 0. Rebecca purple is not half of that. Its row is 102 51 153.

How do the named shades differ?

They differ by the sRGB triple in the spec, and by the lightness computed from that triple. The table is ordered by that computed lightness, low to high. Ties stay in the order they were calculated.

Shade HEX RGB CMYK (computed) HSL (computed)
Indigo #4B0082 75, 0, 130 42, 100, 0, 49 275, 100%, 25%
Purple #800080 128, 0, 128 0, 100, 0, 50 300, 100%, 25%
Dark magenta #8B008B 139, 0, 139 0, 100, 0, 45 300, 100%, 27%
Rebecca purple #663399 102, 51, 153 33, 67, 0, 40 270, 50%, 40%
Dark violet #9400D3 148, 0, 211 30, 100, 0, 17 282, 100%, 41%
Medium violet red #C71585 199, 21, 133 0, 89, 33, 22 322, 81%, 43%
Dark orchid #9932CC 153, 50, 204 25, 75, 0, 20 280, 61%, 50%
Blue violet #8A2BE2 138, 43, 226 39, 81, 0, 11 271, 76%, 53%
Medium orchid #BA55D3 186, 85, 211 12, 60, 0, 17 288, 59%, 58%
Medium purple #9370DB 147, 112, 219 33, 49, 0, 14 260, 60%, 65%
Orchid #DA70D6 218, 112, 214 0, 49, 2, 15 302, 59%, 65%
Violet #EE82EE 238, 130, 238 0, 45, 0, 7 300, 76%, 72%
Plum #DDA0DD 221, 160, 221 0, 28, 0, 13 300, 47%, 75%
Thistle #D8BFD8 216, 191, 216 0, 12, 0, 15 300, 24%, 80%
Lavender #E6E6FA 230, 230, 250 8, 8, 0, 2 240, 67%, 94%

Indigo and purple both land at 25% computed lightness, with different hues: 275 degrees and 300 degrees. Medium violet red sits at hue 322, the row that leans farthest toward red in this set. Lavender’s computed hue is 240, which is the blue side of the set, at 94% lightness.

CMYK uses the simple profile-free conversion: black is one minus the strongest RGB channel, and the other inks are scaled from what remains. Treat every CMYK cell as a starting mix, computed from the sRGB value, not as a press proof.

Which purple passes text contrast?

Contrast here is computed with the WCAG 2.2 formula. Relative luminance is L = 0.2126 R + 0.7152 G + 0.0722 B after the sRGB channel is linearized. The contrast ratio is (L1 + 0.05) / (L2 + 0.05). WCAG 2.2 says ratios can range from 1:1 to 21:1.

The same guideline asks for at least 4.5:1 for normal text at level AA, 3:1 for large-scale text at AA, and 7:1 for normal text at AAA. Large-scale text, in the WCAG definition, is at least 18 point, or 14 point bold. The ratios below are computed, not copied from a contrast checker.

Shade on white Computed ratio AA normal text (4.5:1)
Indigo #4B0082 12.95:1 Passes, and clears 7:1
Purple #800080 9.42:1 Passes, and clears 7:1
Dark magenta #8B008B 8.50:1 Passes, and clears 7:1
Rebecca purple #663399 8.41:1 Passes, and clears 7:1
Dark violet #9400D3 6.56:1 Passes AA, misses 7:1
Blue violet #8A2BE2 5.96:1 Passes AA, misses 7:1
Dark orchid #9932CC 5.70:1 Passes AA, misses 7:1
Medium violet red #C71585 5.42:1 Passes AA, misses 7:1
Medium orchid #BA55D3 3.94:1 Misses AA for normal text
Medium purple #9370DB 3.76:1 Misses AA for normal text
Orchid #DA70D6 2.89:1 Misses the 3:1 large-text bar
Violet #EE82EE 2.32:1 Use as a fill, not as small text
Plum #DDA0DD 2.07:1 Use as a fill, not as small text
Thistle #D8BFD8 1.70:1 Use as a fill, not as small text
Lavender #E6E6FA 1.23:1 Use as a fill, not as small text

Purple on black computes to 2.23:1, and indigo on black computes to 1.62:1. Both miss 3:1, so those dark names want a light background.

The light names want dark text. Black on thistle computes to 12.36:1, and black on lavender computes to 17.06:1.

Medium purple on white is 3.76:1, so it clears the 3:1 large-text bar and misses 4.5:1. Orchid at 2.89:1 misses both of those bars on white.

How should you use purple on a page?

Use the dark named purples for text and the light ones for fills. The keyword purple is already a dark color, at 25% computed lightness, and its computed contrast on white clears AAA for normal text.

Keep one dark purple for headings or links and one light purple for a panel. Stacking indigo, dark violet, and blue violet in the same line of text makes the hues fight, because those rows are not the same hue angle. Medium violet red is the row to treat as a pink-purple accent, not as a second copy of #800080.

If a design tool has no keyword field, paste the hex from the table. If it has no hex field, paste the decimal RGB. Leave CMYK for print and expect a profile to move it. The computed values are there so the conversion is repeatable, not so a printer can skip a proof.

Frequently asked questions

Are magenta and fuchsia the same code?

Yes. In the CSS Color Level 4 named-color table, magenta and fuchsia are both #FF00FF, decimal 255 0 255. Computed from that sRGB value, HSL is 300 degrees, 100% saturation, and 50% lightness, and CMYK is 0, 100, 0, 0. Computed contrast is 3.14:1 on white and 6.70:1 on black. The 3.14:1 pair meets the 3:1 large-text AA bar and misses the 4.5:1 bar for normal text. Neither keyword is the named color purple, which stays at #800080.

What is rebeccapurple?

Rebecca purple is the named color #663399, decimal 102 51 153, in the CSS Color Level 4 table. The spec notes the addition of that name in its history. Computed HSL is 270 degrees, 50% saturation, and 40% lightness. Computed CMYK is 33, 67, 0, 40. Computed contrast is 8.41:1 on white, which clears the 7:1 AAA bar for normal text, and 2.50:1 on black, which does not clear 3:1. It is a separate keyword from purple.

Which named purple is lightest?

Among the fifteen names in the table, lavender is lightest by computed HSL lightness, at 94%. Its sRGB value is 230 230 250, hex #E6E6FA. Thistle is next at 80% lightness, then plum at 75%. Those lightness numbers are computed, not printed in the W3C table. Lavender's computed contrast on white is 1.23:1, so it is a background tint. Put dark text on it. Black on lavender computes to 17.06:1.

Does the keyword care about letter case?

The keyword does not. CSS Color Level 4 says the named colors are ASCII case-insensitive, so purple and PURPLE resolve to the same sRGB color. The table prints the hex in lowercase as #800080. MDN's named-color page documents the same keyword system for stylesheets. The International Color Consortium's sRGB registry lists the encoding's white point as chromaticity x = 0.3127, y = 0.3290 (D65), and points to IEC 61966-2-1:1999 for the standard. That registry is the color space these named colors resolve into.

Why is purple in the basic sixteen?

CSS Color Level 4 says sixteen of the named colors came from the VGA palette and were adopted into HTML. The list is aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. Most of the other names came from an X11 set used on Unix-derived systems and later adopted into SVG. The spec says the names are standardized because they were already widespread, and that the names are not evenly spread through the sRGB volume.

Sources