CSS Function

opacity()

The opacity() filter function applies transparency to an element's rendering, affecting both content and background.

Syntax

filter: opacity(amount)

Parameters

NameTypeRequiredDescription
amountnumber | percentageYesOpacity level: 0/0% (fully transparent) to 1/100% (fully opaque)

Examples

Half transparent

Makes the element 50% transparent.

css
filter: opacity(0.5);

Combined filters

Slightly transparent with a blur.

css
filter: opacity(0.8) blur(2px);

Tailwind filter opacity

Tailwind's opacity-50 utility (uses the opacity property, not filter).

html
<img class="opacity-50" 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:

opacity-{value}: opacity-0, opacity-50, opacity-100, etc.

Frequently Asked Questions

What is the difference between filter: opacity() and the opacity property?
filter: opacity() can be hardware-accelerated and combined with other filters in a single pipeline. The opacity property creates a new stacking context.
Does opacity affect child elements?
Yes. Both filter: opacity() and the opacity property affect the entire element including children. For background-only transparency, use rgba/hsla background colors.

Explore CSS Color Tools

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

Open Tools