# lab()

> The `lab()` CSS function specifies a color using the CIELAB color space, which describes colors based on lightness and two color components.

## What is the lab() color function in CSS?

The color function that defines colors using the CIELAB color space, which separates lightness from two color components: 'a' (from green to red) and 'b' (from blue to yellow). It provides a more perceptually uniform way of defining colors, making it easier to achieve consistent color contrasts.

- Topic: Colors
- Type: function
- Browser support: Chrome 111+, Chrome Android 111+, Edge 111+, Firefox 113+, Firefox Android 113+, Safari 15+, Safari iOS 15+

## Example

Wrong:

```css
.brand {
  color: lab(0.6 40 -20);
}
```

Right:

```css
.brand {
  color: lab(60% 40 -20);
}
```

In `lab()` lightness runs from 0 to 100, so a value under 1 is almost black.

## Common mistakes

- Writing lightness as a value under 1, copied from `oklab()`, which gives a near-black color.
- Using commas between channels, which `lab()` doesn't accept.

## Key points

- Lightness is a percentage or a number from 0 to 100, not 0 to 1 as in `oklab()`.
- Hue changes use `lch()` or `oklch()` instead of guessing 'a' and 'b' values.
- Colors outside sRGB have a fallback declared before them.

## Interview questions

### What is the difference between lab() and oklab()?

Both use lightness plus 'a' and 'b' axes. Oklab fixes hue shifts that CIELAB has, especially in blues, so it is usually preferred for UI colors.

### What is the difference between lab() and lch()?

They use the same color space. `lab()` uses 'a' and 'b' axes, while `lch()` expresses them as chroma and a hue angle.

## Related cards

- [lch()](https://wonderium.dev/css/lch.md)
- [oklab()](https://wonderium.dev/css/oklab.md)
- [color()](https://wonderium.dev/css/color.md)
- [color-mix()](https://wonderium.dev/css/color-mix.md)
- [rgb() / rgba()](https://wonderium.dev/css/rgb.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/lab
- Last updated: 2026-11-25
