opacity

The opacity CSS property specifies the opacity to the element as a whole, including its contents, rather than applying it to each descendant individually. This means that, for example, an opaque child occluding part of the element's background will continue to do so even when opacity is less than 1, but the element and child as a whole will show the underlying page through themselves.

Syntax

CSS

opacity: value;

JS

object.style.opacity = "value";

Values

<'opacity'> = <alpha-value>
<alpha-value> = <number> | <percentage>
<number>

An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.

<percentage>

Specifies the percentage using a number followed by a percent sign (%).

Initial

1

Examples

number

percentage

JS

World Wide Web Consortium (W3C)

Home Menu