About Gray
Gray (gray) is a medium, muted gray with the hex code #808080, or rgb(128, 128, 128). In HSL it sits at a hue of 0°, 0% saturation and 50% lightness. CSS also accepts the spelling grey for exactly the same color. It is one of the 148 named colors every browser understands, so you can write color: gray; instead of the hex value.
Using Gray for text and backgrounds
| Pairing | Contrast ratio | WCAG |
|---|---|---|
| Gray text on white | 3.95 : 1 | AA large text only |
| Gray text on black | 5.32 : 1 | AA |
On a gray background, use black text (5.32 : 1). WCAG asks for at least 4.5 : 1 for body text and 3 : 1 for large text. Check other pairs with the Contrast Checker.
CSS
.element {
color: gray; /* or #808080 */
background-color: #808080;
border: 1px solid rgb(128 128 128 / 50%);
}
Similar named colors
Slate Gray (#708090), Light Slate Gray (#778899), Dim Gray (#696969), Cadet Blue (#5f9ea0), Dark Sea Green (#8fbc8f), Rosy Brown (#bc8f8f).