# opacity function

The `opacity` function allows you to change a transparency of the background image. The value of `100%` or `1` leaves the image at its original transparency. The value of `0` means that the image will become completely transparent. Any number located in this range specifies partial transparency of the background. A negative value cannot be specified. The default value is `1`.

## Syntax

`selector { filter: opacity(number); }`

## Example

Let's set the transparency of our image to `50%`:

`<div id="elem"></div>` `#elem { filter: opacity(50%); background: url("bg.png") center / cover no-repeat; width: 400px; height: 300px; border: 1px solid black; }`

:

## Example

Now let's set the transparency to `100%`:

`<div id="elem"></div>` `#elem { filter: opacity(100%); background: url("bg.png") center / cover no-repeat; width: 400px; height: 300px; border: 1px solid black; }`

:

## Example

Now let's set the `opacity` function to a value equal to `0`:

`<div id="elem"></div>` `#elem { filter: opacity(0); background: url("bg.png") center / cover no-repeat; width: 400px; height: 300px; border: 1px solid black; }`

:

## See also

- the `blur` function
  that blurs a background
- the `brightness` function
  that sets a background brightness
- the `contrast` function
  that sets a background contrast
- the `drop-shadow` function
  that sets a background shadow
- the `hue-rotate` function
  that sets a background hue
- the `invert` function
  that inverts background colors
- the `sepia` function
  that converts a background to sepia
- the `background` property
  that is a shorthand property for a background
- the `background-image` property
  with that you can set a background image for a block

← →
↑
en ru