Transparency and Opacity in CSS
Learn to use CSS opacity and visibility to create dynamic, engaging designs.
In this lesson, we’ll look at CSS properties that allow us to control the transparency and visibility of elements on a web page. Understanding how to manipulate these properties is instrumental in creating dynamic and interactive user experiences. We’ll explore the opacity
and the visibility
properties to control the rendering of elements.
Understanding opacity
The opacity
property in CSS sets the transparency level of an element and its children. It accepts a value between 0
(completely transparent) and 1
(completely opaque). For intermediate values, the element becomes partially transparent, with values closer to 0 being more transparent and values closer to 1 being more opaque.
In the CSS file above , we set the opacity of the partially opaque image to 0.5
, making it 50% transparent.