effects

opacity

Sets the transparency of an entire element, including its background, borders, and children. Values range from 0 (fully transparent) to 1 (fully opaque).

opacity: <number> (0 to 1) | <percentage>

Common values

Value Effect
1 Fully opaque
0 Fully transparent but still occupies space
0.5 Half transparent
0% Percentage form of 0
60% Percentage form for 0.6

Examples

.disabled { opacity: 0.5; pointer-events: none; }

Dimmed and non-interactive control

.fade-in { opacity: 0; transition: opacity .3s; } .fade-in.show { opacity: 1; }

Fade transition triggered by a class

.overlay { background: black; opacity: .6; }

Semi-transparent modal backdrop

Gotcha

opacity affects children too and creates a new stacking context; for background-only transparency, use rgba/hsla instead.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox