CSS opacity() function
- Previous Page CSS oklch() function
- Next Page CSS perspective() function
- Go to the Previous Level CSS Function Reference Manual
Definition and usage
CSS opacity()
Filter functions are used to apply transparency effects to elements.
- 100% (or 1) will have no effect
- 50% (or 0.5) will make the element 50% transparent
- 0% (or 0) will make the element completely transparent
Instance
Example 1
Set different transparency for images:
#img1 { filter: opacity(80%); } #img2 { filter: opacity(50%); } #img3 { filter: opacity(0.2); }
Example 2
to opacity()
with backdrop-filter
Properties used together:
div.transbox { background-color: rgba(255, 255, 255, 0.4); -webkit-backdrop-filter: opacity(50%); backdrop-filter: opacity(50%); padding: 20px; margin: 30px; font-weight: bold; }
CSS syntax
opacity(amount)
Value | Description |
---|---|
amount |
Optional. Specify the value or percentage of transparency. 0% (or 0) will make the element completely transparent. 100% (or 1) represents the original image (no effect). The default value is 1. |
Technical details
Version: | CSS Filter Effects Module Level 1 |
---|
Browser support
The numbers in the table represent the first browser version to fully support this function.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
18 | 12 | 35 | 6 | 15 |
Related pages
Reference:CSS filter attribute
Reference:CSS blur() function
Reference:CSS brightness() function
Reference:CSS contrast() function
Reference:CSS drop-shadow() function
Reference:CSS grayscale() function
Reference:CSS hue-rotate() function
Reference:CSS invert() function
Reference:CSS saturate() function
Reference:CSS sepia() function
- Previous Page CSS oklch() function
- Next Page CSS perspective() function
- Go to the Previous Level CSS Function Reference Manual