Style opacity property

Definition and Usage

opacity The property sets or returns the opacity level of an element.

The opacity-level of an element describes the transparency level, where 1 Indicates no transparency,0.5 Indicates 50% transparency,0 Indicates complete transparency.

See also:

CSS Reference Manual:Opacity property

Example

Make the DIV element transparent:

document.getElementById("myDIV").style.opacity = "0.5";

Try it yourself

Syntax

Return opacity property:

object.style.opacity

Set opacity property:

object.style.opacity = "number|initial|inherit"

Property value

Value Description
number Specify opacity. From 0.0 (fully transparent) to 1.0 (fully opaque).
initial Set this property to its default value. See also initial.
inherit This property inherits from its parent element. See also inherit.

Technical details

Default value: 1
Return value: A string that represents the opacity level of the element.
CSS Version: CSS3

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support