Skip to content

Basic HTML and CSS color

Gray #808080

Gray (CSS keyword gray) has the hex code #808080 and the RGB value rgb(128, 128, 128): a medium neutral gray.

Gray#808080

Gray (#808080) is one of the 16 original HTML colors: exactly half intensity on each channel, but only about 22% relative luminance because sRGB is not linear. It is darker than darkgray.

The keyword grey has exactly the same value (#808080); browsers treat them as the same color.

Color codes for Gray

Color codes for Gray
CSS keywordgray
HEX#808080
RGBrgb(128, 128, 128)
HSLhsl(0, 0%, 50%)
HWBhwb(0 50% 50%)
OKLCHoklch(60% 0 0)
CMYK (naive, no ICC profile)cmyk(0%, 0%, 0%, 50%)
Decimal8,421,504
Hue familyGrays and black
Same value asgrey

Contrast and accessibility

On gray, black text has a contrast ratio of 5.31:1 and passes AA for normal text; white text reaches 3.94: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 gray5.31:1PassPassFailPass37.2
White text on gray3.94:1FailPassFailFail−72.4
Gray text on white3.94:1FailPassFailFail66.9
Gray text on black5.31:1PassPassFailPass−34.8

Tints and shades

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

Tints (mixed with white)

  1. 5%
    #868686
  2. 15%
    #939393
  3. 25%
    #a0a0a0
  4. 35%
    #acacac
  5. 45%
    #b9b9b9
  6. 55%
    #c6c6c6
  7. 65%
    #d3d3d3
  8. 75%
    #dfdfdf
  9. 85%
    #ececec
  10. 95%
    #f9f9f9

Shades (mixed with black)

  1. 5%
    #7a7a7a
  2. 15%
    #6d6d6d
  3. 25%
    #606060
  4. 35%
    #535353
  5. 45%
    #464646
  6. 55%
    #3a3a3a
  7. 65%
    #2d2d2d
  8. 75%
    #202020
  9. 85%
    #131313
  10. 95%
    #060606

Color harmonies

Rotating the hue in OKLCH while keeping lightness and chroma, gray's complementary color is #808080 (close to gray), its analogous colors are #808080 and #808080, and its triadic partners are #808080 and #808080. For text on top, black gives the higher contrast.

Color harmonies
HarmonyRotationColor
Complementary+180°#808080
Analogous−30°, +30°#808080#808080
Triadic+120°, +240°#808080#808080
Split-complementary+150°, +210°#808080#808080

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?

Gray is close to neutral: its OKLCH chroma is only 0.000, so its temperature comes from context. It has no perceptible hue.

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
slategray#7080903.2
lightslategray#7788993.8
dimgray#6969697.9

Nearest Tailwind v4 colors

Nearest Tailwind v4 colors
ColorHEXΔE OK
olive-500#7c7c673.7
neutral-500#7373734.4
mist-500#67787c4.5

Code snippets

CSS
.element {
  color: gray;
  background-color: #808080;
  border-color: rgb(128 128 128);
  outline-color: oklch(60% 0 0);
}
Tailwind CSS
<div class="bg-[#808080] text-black">...</div>

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

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

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

const gray = Color(0xFF808080);
Android XML
<!-- res/values/colors.xml -->
<color name="gray">#808080</color>

Frequently asked questions

What is the hex code for gray?
The hex code for gray is #808080. The same color is rgb(128, 128, 128), hsl(0, 0%, 50%) and oklch(60% 0 0), and in CSS you can also write the keyword gray directly.
Is gray a warm or cool color?
Gray is close to neutral: its OKLCH chroma is only 0.000, so its temperature comes from context. It has no perceptible hue.
What colors go with gray?
Rotating the hue in OKLCH while keeping lightness and chroma, gray's complementary color is #808080 (close to gray), its analogous colors are #808080 and #808080, and its triadic partners are #808080 and #808080. For text on top, black gives the higher contrast.
Can you use white text on gray?
White text on gray has a contrast ratio of 3.94:1, which passes AA only for large text (24 px, or 18.66 px bold, and up) under WCAG 2.2. Black text reaches 5.31:1 and passes AA for normal text but not AAA. In APCA terms that is Lc −72.4 for white and Lc 37.2 for black.
Is gray the same as grey?
Yes. Both keywords are #808080 (rgb(128, 128, 128)). CSS Color 4 keeps both for compatibility, so use whichever your codebase already uses.

Last reviewed by Arielton Oberek.