Latest web development tutorials

HTML DOM Style opacity property

Style Object Reference Style Objects

Examples

Let translucent DIV element:

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

try it"

Definition and Usage

opacity property sets or returns the opacity of the element.

Opacity level elements describe the level of transparency, when the opacity of 1 is fully opaque, translucent represented 0.5 when the opacity is completely transparent when the opacity of 0:00.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support opacity property.

Note: IE8 and earlier versions support another alternative of the property attribute that filter properties.


grammar

Back opacity attributes:

object .style.opacity

Set the opacity properties:

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

Property Value

描述
number 规定不透明度。从 0.0 (完全透明)到 1.0(完全不透明)。
initial 设置该属性为它的默认值。请参阅 initial
inherit 从父元素继承该属性。请参阅 inherit

technical details

Defaults: 1
return value: String representing the opacity attributes of the element.
CSS version CSS3


related articles

CSS Reference: Opacity property


Style Object Reference Style Objects