Skip to content

CSS named color

MidnightBlue #191970

MidnightBlue (CSS keyword midnightblue) has the hex code #191970 and the RGB value rgb(25, 25, 112): a very dark, moderately saturated blue.

MidnightBlue#191970

A very dark blue with a slight indigo cast (#191970), a little lighter and less saturated than navy. Often used as a softer alternative to black in dark themes.

Color codes for MidnightBlue

Color codes for MidnightBlue
CSS keywordmidnightblue
HEX#191970
RGBrgb(25, 25, 112)
HSLhsl(240, 64%, 27%)
HWBhwb(240 10% 56%)
OKLCHoklch(28.8% 0.144 272.8)
CMYK (naive, no ICC profile)cmyk(78%, 78%, 0%, 56%)
Decimal1,644,912
Hue familyBlues

Contrast and accessibility

On midnightblue, white text has a contrast ratio of 14.84:1 and passes AAA at any text size; black text reaches 1.41: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 midnightblue1.41:1FailFailFailFail0.0
White text on midnightblue14.84:1PassPassPassPass−104.0
Midnightblue text on white14.84:1PassPassPassPass101.0
Midnightblue text on black1.41:1FailFailFailFail0.0

Tints and shades

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

Tints (mixed with white)

  1. 5%
    #252577
  2. 15%
    #3c3c85
  3. 25%
    #535394
  4. 35%
    #6a6aa2
  5. 45%
    #8181b0
  6. 55%
    #9898bf
  7. 65%
    #afafcd
  8. 75%
    #c6c6db
  9. 85%
    #ddddea
  10. 95%
    #f4f4f8

Shades (mixed with black)

  1. 5%
    #18186a
  2. 15%
    #15155f
  3. 25%
    #131354
  4. 35%
    #101049
  5. 45%
    #0e0e3e
  6. 55%
    #0b0b32
  7. 65%
    #090927
  8. 75%
    #06061c
  9. 85%
    #040411
  10. 95%
    #010106

Color harmonies

Rotating the hue in OKLCH while keeping lightness and chroma, midnightblue's complementary color is #382900 (close to darkslategray), its analogous colors are #002D57 and #3A0663, and its triadic partners are #5D0000 and #00380D. For text on top, white gives the higher contrast.

Color harmonies
HarmonyRotationColor
Complementary+180°#382900
Analogous−30°, +30°#002d57#3a0663
Triadic+120°, +240°#5d0000#00380d
Split-complementary+150°, +210°#471e00#233100

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?

MidnightBlue is a cool color: its hue is 240° on the HSL wheel, in the green, blue and violet range that is conventionally called cool.

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
navy#0000805.4
darkblue#00008b6.1
indigo#4b008210.1

Nearest Tailwind v4 colors

Nearest Tailwind v4 colors
ColorHEXΔE OK
violet-950#2f0d684.6
blue-950#1624565.4
indigo-950#1e1a4d6.4

Code snippets

CSS
.element {
  color: midnightblue;
  background-color: #191970;
  border-color: rgb(25 25 112);
  outline-color: oklch(28.8% 0.144 272.8);
}
Tailwind CSS
<div class="bg-[#191970] text-white">...</div>

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

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

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

const midnightblue = Color(0xFF191970);
Android XML
<!-- res/values/colors.xml -->
<color name="midnightblue">#191970</color>

Frequently asked questions

What is the hex code for midnightblue?
The hex code for midnightblue is #191970. The same color is rgb(25, 25, 112), hsl(240, 64%, 27%) and oklch(28.8% 0.144 272.8), and in CSS you can also write the keyword midnightblue directly.
Is midnightblue a warm or cool color?
MidnightBlue is a cool color: its hue is 240° on the HSL wheel, in the green, blue and violet range that is conventionally called cool.
What colors go with midnightblue?
Rotating the hue in OKLCH while keeping lightness and chroma, midnightblue's complementary color is #382900 (close to darkslategray), its analogous colors are #002D57 and #3A0663, and its triadic partners are #5D0000 and #00380D. For text on top, white gives the higher contrast.
Can you use white text on midnightblue?
White text on midnightblue has a contrast ratio of 14.84:1, which passes both AA and AAA under WCAG 2.2. Black text reaches 1.41:1 and fails AA even for large text. In APCA terms that is Lc −104.0 for white and Lc 0.0 for black.
What is the RGB value of midnightblue?
MidnightBlue is rgb(25, 25, 112): red 25, green 25 and blue 112 on the 0 to 255 scale, or 9.8%, 9.8% and 43.9%. As a decimal integer it is 1644912.

Last reviewed by Arielton Oberek.