CSS Function

contrast()

The contrast() filter function adjusts the contrast of an element's rendering, affecting the difference between light and dark areas.

Syntax

filter: contrast(amount)

Parameters

NameTypeRequiredDescription
amountnumber | percentageYesContrast multiplier: 0 (solid gray), 1/100% (original), >1 (higher contrast)

Examples

High contrast

Increases contrast by 50%.

css
img {
  filter: contrast(1.5);
}

Low contrast (muted)

Reduces contrast for a washed-out look.

css
.muted {
  filter: contrast(0.7);
}

Tailwind utility

Tailwind provides contrast-{value} utilities.

html
<img class="contrast-125" src="photo.jpg" />

Browser Support

Chrome

v18++

Firefox

v35++

Safari

v6++

Edge

v12++

Opera

v15++

Tailwind Equivalent

You can achieve similar results in Tailwind CSS using the following utility classes:

contrast-{value}: contrast-0, contrast-50, contrast-100, contrast-125, contrast-200

Frequently Asked Questions

What does contrast(0) look like?
contrast(0) produces a flat medium gray. All pixel values converge to 50% gray, removing all visual detail.
Can I use contrast for accessibility?
As a filter, yes, but it is better to design with sufficient contrast from the start. Use WCAG contrast ratio tools rather than relying on CSS filters.

Explore CSS Color Tools

Try our free tools to work with contrast() and other CSS color functions.

Open Tools