The opacity property sets how opaque an element is — the opposite of transparency. A value of 1 is fully solid. A value of 0 is fully invisible. Values in between let content behind the element show through.
It applies to the whole element: background, border, text, and children. For a transparent background only, use a color with an alpha channel instead, such as on background-color.
Baseline · Widely available.
Not deprecated and not experimental. Number values (0–1) are universal. Percentage values (0%–100%) need modern browsers (Chrome 78+, Firefox 70+, Safari 13.1+).
Bottom line: Safe for production with number values. Prefer 0.5 over 50% if you must support older browsers. This is not a JavaScript runtime API.
Remember
Key Takeaways
Role: set how opaque the whole element is, from invisible (0) to solid (1).
Initial:1. Not inherited. Children still look faded with the parent.
Background only? Use an alpha color instead of opacity.
Invisible ≠ gone:opacity: 0 can still receive clicks and keep layout space.
One line:opacity fades the entire painted layer — use alpha colors when only the fill should be see-through.
Frequently Asked Questions
It sets how opaque an element is. 1 (or 100%) is fully solid. 0 (or 0%) is fully transparent. Values in between make the whole element see-through.
Yes. Opacity applies to the element as a whole, including background, border, text, and children. Children cannot look more opaque than their parent.
opacity fades the entire element. A color with an alpha channel, such as rgb(0 0 0 / 40%), can fade only the background while text stays fully opaque.
No. It is invisible but still in the layout and can still receive clicks and focus. Use pointer-events, visibility, or display when you need different hide behavior.
No. The initial value is 1. Children are painted with the parent’s transparency because the whole layer is composited together.
Number values are Baseline Widely available in all modern browsers, including Internet Explorer 9+. Percentage values need Chrome 78+, Firefox 70+, Safari 13.1+, or Edge 79+. It is a browser CSS property, not a Node.js feature.