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) 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
| CSS keyword | gray |
|---|---|
| HEX | #808080 |
| RGB | rgb(128, 128, 128) |
| HSL | hsl(0, 0%, 50%) |
| HWB | hwb(0 50% 50%) |
| OKLCH | oklch(60% 0 0) |
| CMYK (naive, no ICC profile) | cmyk(0%, 0%, 0%, 50%) |
| Decimal | 8,421,504 |
| Hue family | Grays and black |
| Same value as | grey |
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.
| Pair | Ratio | AA | AA large | AAA | AAA large | APCA Lc |
|---|---|---|---|---|---|---|
| Black text on gray | 5.31:1 | Pass | Pass | Fail | Pass | 37.2 |
| White text on gray | 3.94:1 | Fail | Pass | Fail | Fail | −72.4 |
| Gray text on white | 3.94:1 | Fail | Pass | Fail | Fail | 66.9 |
| Gray text on black | 5.31:1 | Pass | Pass | Fail | Pass | −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)
- 5%
#868686 - 15%
#939393 - 25%
#a0a0a0 - 35%
#acacac - 45%
#b9b9b9 - 55%
#c6c6c6 - 65%
#d3d3d3 - 75%
#dfdfdf - 85%
#ececec - 95%
#f9f9f9
Shades (mixed with black)
- 5%
#7a7a7a - 15%
#6d6d6d - 25%
#606060 - 35%
#535353 - 45%
#464646 - 55%
#3a3a3a - 65%
#2d2d2d - 75%
#202020 - 85%
#131313 - 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.
| Harmony | Rotation | Color |
|---|---|---|
| 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
| Color | HEX | ΔE OK |
|---|---|---|
| slategray | #708090 | 3.2 |
| lightslategray | #778899 | 3.8 |
| dimgray | #696969 | 7.9 |
Nearest Tailwind v4 colors
| Color | HEX | ΔE OK |
|---|---|---|
| olive-500 | #7c7c67 | 3.7 |
| neutral-500 | #737373 | 4.4 |
| mist-500 | #67787c | 4.5 |
Code snippets
.element {
color: gray;
background-color: #808080;
border-color: rgb(128 128 128);
outline-color: oklch(60% 0 0);
}<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 */import SwiftUI
extension Color {
static let gray = Color(red: 0.502, green: 0.502, blue: 0.502)
}import androidx.compose.ui.graphics.Color
val Gray = Color(0xFF808080)import 'package:flutter/material.dart';
const gray = Color(0xFF808080);<!-- 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.