Skip to content

Basic HTML and CSS color

Black #000000

Black (CSS keyword black) has the hex code #000000 and the RGB value rgb(0, 0, 0): pure black.

Black#000000

Black (#000000) is one of the 16 original HTML colors. Pure black text on a pure white page has the maximum WCAG contrast ratio of 21:1, which some designers soften with a near-black for long reading.

Color codes for Black

Color codes for Black
CSS keywordblack
HEX#000000
RGBrgb(0, 0, 0)
HSLhsl(0, 0%, 0%)
HWBhwb(0 0% 100%)
OKLCHoklch(0% 0 0)
CMYK (naive, no ICC profile)cmyk(0%, 0%, 0%, 100%)
Decimal0
Hue familyGrays and black

Contrast and accessibility

On black, white text has a contrast ratio of 21.00:1 and passes AAA at any text size; black text reaches 1.00: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 black1.00:1FailFailFailFail0.0
White text on black21.00:1PassPassPassPass−107.9
Black text on white21.00:1PassPassPassPass106.0
Black text on black1.00:1FailFailFailFail0.0

Tints and shades

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

Tints (mixed with white)

  1. 5%
    #0d0d0d
  2. 15%
    #262626
  3. 25%
    #404040
  4. 35%
    #595959
  5. 45%
    #737373
  6. 55%
    #8c8c8c
  7. 65%
    #a6a6a6
  8. 75%
    #bfbfbf
  9. 85%
    #d9d9d9
  10. 95%
    #f2f2f2

Shades (mixed with black)

  1. 5%
    #000000
  2. 15%
    #000000
  3. 25%
    #000000
  4. 35%
    #000000
  5. 45%
    #000000
  6. 55%
    #000000
  7. 65%
    #000000
  8. 75%
    #000000
  9. 85%
    #000000
  10. 95%
    #000000

Color harmonies

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

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

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?

Black 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
midnightblue#19197032.2
navy#00008033.0
darkblue#00008b35.0

Nearest Tailwind v4 colors

Nearest Tailwind v4 colors
ColorHEXΔE OK
gray-950#03071213.3
slate-950#02061813.6
zinc-950#09090b14.1

Code snippets

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

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

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

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

const black = Color(0xFF000000);
Android XML
<!-- res/values/colors.xml -->
<color name="black">#000000</color>

Frequently asked questions

What is the hex code for black?
The hex code for black is #000000. The same color is rgb(0, 0, 0), hsl(0, 0%, 0%) and oklch(0% 0 0), and in CSS you can also write the keyword black directly.
Is black a warm or cool color?
Black 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 black?
Rotating the hue in OKLCH while keeping lightness and chroma, black's complementary color is #000000 (close to black), its analogous colors are #000000 and #000000, and its triadic partners are #000000 and #000000. For text on top, white gives the higher contrast.
Can you use white text on black?
White text on black has a contrast ratio of 21.00:1, which passes both AA and AAA under WCAG 2.2. Black text reaches 1.00:1 and fails AA even for large text. In APCA terms that is Lc −107.9 for white and Lc 0.0 for black.
What is the RGB value of black?
Black is rgb(0, 0, 0): red 0, green 0 and blue 0 on the 0 to 255 scale, or 0.0%, 0.0% and 0.0%. As a decimal integer it is 0.

Last reviewed by Arielton Oberek.