Opacity and RGBA Transparency
Control element transparency using the opacity property and rgba() color values.
The opacity Property
The opacity property sets the transparency of the entire element including its children and content. Values range from 0 (fully transparent) to 1 (fully opaque).
.overlay {
background: black;
opacity: 0.5;
}opacity Affects All Children
A key caveat: opacity affects the whole element tree. Text, images, and child elements inside an element with opacity: 0.5 are all 50% transparent — you cannot make children more opaque than their parent.
All lessons in this course
- Color Values: Named, Hex, RGB, HSL
- Background Color and Image
- Gradients: Linear and Radial
- Opacity and RGBA Transparency