Property Description
The opacity property specifies the opacity level of the element.
This property has the following syntax:
opacity: number|initial|inherit;
Property Values
| Value | Description |
|---|---|
| number | Sets the opacity for the element. The value is a floating point number from 0.0 (fully transparent) to 1.0 (fully opaque) |
| initial | Specifies that the value of the property should be set to the default value |
| inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
The following example shows the basic use of this property:
<div style="opacity:0.10;">
This text has opacity = 0.10
</div>
<div style="opacity:0.25;">
This text has opacity = 0.25
</div>
<div style="opacity:0.5;">
This text has opacity = 0.5
</div>
<div style="opacity:0.75;">
This text has opacity = 0.75
</div>
<div style="opacity:1.0;">
This text has opacity = 1.0
</div>
This produces the following result:
This text has opacity = 0.10
This text has opacity = 0.25
This text has opacity = 0.50
This text has opacity = 0.75
This text has opacity = 1.0
Browser Support
| Chrome | Firefox | IE | Safari | Opera |
|---|---|---|---|---|
| 4.0 | 2.0 | 9.0 | 3.1 | 9.0 |
Note: For IE8 and earlier, use filter property, eg. filter:Alpha(opacity=50).
Miscellaneous Information
| Inherited: | No |
|---|---|
| Defined In: | CSS3 |
| Default Value: | 1 |
