Skip to content

Basic HTML and CSS color

Purple #800080

Purple (CSS keyword purple) has the hex code #800080 and the RGB value rgb(128, 0, 128): a dark, vivid purple.

Purple#800080

Purple (#800080) is one of the 16 original HTML colors, half-intensity red and blue. In X11, purple was a brighter violet (#a020f0), one of the four names where CSS and X11 disagree.

Color codes for Purple

Color codes for Purple
CSS keywordpurple
HEX#800080
RGBrgb(128, 0, 128)
HSLhsl(300, 100%, 25%)
HWBhwb(300 0% 50%)
OKLCHoklch(42.1% 0.193 328.4)
CMYK (naive, no ICC profile)cmyk(0%, 100%, 0%, 50%)
Decimal8,388,736
Hue familyPurples and violets

Contrast and accessibility

On purple, white text has a contrast ratio of 9.41:1 and passes AAA at any text size; black text reaches 2.22:1.

WCAG 2.2 contrast ratios (success criteria 1.4.3 and 1.4.6: AA needs 4.5:1 for normal text and 3:1 for large text, AAA needs 7:1 and 4.5:1). APCA Lc is the lightness contrast from the APCA-W3 0.0.98G model proposed for WCAG 3; a higher absolute value is more readable, and Lc 75 is its suggested minimum for body text.

Contrast and accessibility
PairRatioAAAA largeAAAAAA largeAPCA Lc
Black text on purple2.22:1FailFailFailFail14.4
White text on purple9.41:1PassPassPassPass−94.1
Purple text on white9.41:1PassPassPassPass89.6
Purple text on black2.22:1FailFailFailFail−12.7

Tints and shades

Each step mixes purple with white (tints) or black (shades) in gamma-encoded sRGB, the same result as color-mix(in srgb, purple, white 25%) in CSS.

Tints (mixed with white)

  1. 5%
    #860d86
  2. 15%
    #932693
  3. 25%
    #a040a0
  4. 35%
    #ac59ac
  5. 45%
    #b973b9
  6. 55%
    #c68cc6
  7. 65%
    #d3a6d3
  8. 75%
    #dfbfdf
  9. 85%
    #ecd9ec
  10. 95%
    #f9f2f9

Shades (mixed with black)

  1. 5%
    #7a007a
  2. 15%
    #6d006d
  3. 25%
    #600060
  4. 35%
    #530053
  5. 45%
    #460046
  6. 55%
    #3a003a
  7. 65%
    #2d002d
  8. 75%
    #200020
  9. 85%
    #130013
  10. 95%
    #060006

Color harmonies

Rotating the hue in OKLCH while keeping lightness and chroma, purple's complementary color is #00620F (close to darkgreen), its analogous colors are #5E21A6 and #94004C, and its triadic partners are #654800 and #005A68. For text on top, white gives the higher contrast.

Color harmonies
HarmonyRotationColor
Complementary+180°#00620f
Analogous−30°, +30°#5e21a6#94004c
Triadic+120°, +240°#654800#005a68
Split-complementary+150°, +210°#485500#005e4e

Computed in OKLCH: the hue is rotated by 180° (complementary), ±30° (analogous), ±120° (triadic) and 180° ±30° (split-complementary) while lightness and chroma stay fixed. Results that fall outside sRGB are brought back with the CSS Color 4 gamut mapping algorithm. Because this uses OKLCH, the values differ from tools that rotate hue in HSL, but every color keeps the same perceived lightness.

Warm or cool?

Purple sits on the boundary: its hue of 300° on the HSL wheel is a magenta, which reads warm next to blues and cool next to reds and oranges.

Nearest named and Tailwind colors

Distance is ΔE OK, the Euclidean distance in OKLab multiplied by 100. Values under about 2 are hard to tell apart side by side.

Nearest CSS named colors

Nearest CSS named colors
ColorHEXΔE OK
darkmagenta#8b008b2.8
rebeccapurple#6633998.5
indigo#4b008212.0

Nearest Tailwind v4 colors

Nearest Tailwind v4 colors
ColorHEXΔE OK
fuchsia-900#7213783.2
fuchsia-800#8a01943.8
purple-900#59168b8.7

Code snippets

CSS
.element {
  color: purple;
  background-color: #800080;
  border-color: rgb(128 0 128);
  outline-color: oklch(42.1% 0.193 328.4);
}
Tailwind CSS
<div class="bg-[#800080] text-white">...</div>

/* or register it once in your CSS (Tailwind v4) */
@theme {
  --color-purple: #800080;
}
/* then use bg-purple, text-purple, border-purple */
SwiftUI
import SwiftUI

extension Color {
  static let purple = Color(red: 0.502, green: 0.000, blue: 0.502)
}
Jetpack Compose
import androidx.compose.ui.graphics.Color

val Purple = Color(0xFF800080)
Flutter
import 'package:flutter/material.dart';

const purple = Color(0xFF800080);
Android XML
<!-- res/values/colors.xml -->
<color name="purple">#800080</color>

Frequently asked questions

What is the hex code for purple?
The hex code for purple is #800080. The same color is rgb(128, 0, 128), hsl(300, 100%, 25%) and oklch(42.1% 0.193 328.4), and in CSS you can also write the keyword purple directly.
Is purple a warm or cool color?
Purple sits on the boundary: its hue of 300° on the HSL wheel is a magenta, which reads warm next to blues and cool next to reds and oranges.
What colors go with purple?
Rotating the hue in OKLCH while keeping lightness and chroma, purple's complementary color is #00620F (close to darkgreen), its analogous colors are #5E21A6 and #94004C, and its triadic partners are #654800 and #005A68. For text on top, white gives the higher contrast.
Can you use white text on purple?
White text on purple has a contrast ratio of 9.41:1, which passes both AA and AAA under WCAG 2.2. Black text reaches 2.22:1 and fails AA even for large text. In APCA terms that is Lc −94.1 for white and Lc 14.4 for black.
What is the RGB value of purple?
Purple is rgb(128, 0, 128): red 128, green 0 and blue 128 on the 0 to 255 scale, or 50.2%, 0.0% and 50.2%. As a decimal integer it is 8388736.

Last reviewed by Arielton Oberek.