HTML CSS examples for CSS Property:opacity
The opacity CSS property sets the transparency of an element.
The following table summarizes the opacity Property.
Item | Value |
---|---|
Default value: | 1 (opaque) |
Applies to: | All elements |
Inherited: | No |
Animatable: | Yes. |
The syntax of the property is as follows:
opacity: alphavalue | initial | inherit
The following table describes the values of this property.
Value | Description |
---|---|
alphavalue | A number in the range 0 (fully transparent) to 1 (fully opaque). |
initial | Sets this property to its default value. |
inherit | take the value of its parent element opacity property. |
The example below shows the opacity property.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of CSS3 opacity property</title> <style type="text/css"> img {<!--from w w w. java2 s. c om--> opacity: 0.25; } p { opacity: 0.5; filter: Alpha(opacity=50); } </style> </head> <body> <div> <img src="https://www.java2s.com/style/demo/Opera.png" alt="Sky"> </div> <p>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </p> </body> </html>