opacity changes transparency of an element and all its descendants as a single composited unit.
Usage guidance
- Use subtle opacity for decorative layers.
- Prefer alpha colors (
rgba/hsl / alpha) when only background needs transparency. - Avoid reducing contrast of essential text.
Pitfall
Applying opacity to parent fades child text/icons too, which can harm readability.
Important interview questions and answers
- Q: Opacity vs RGBA background?
A: Opacity affects whole element subtree; RGBA can target specific painted property. - Q: Why can disabled UI using low opacity be problematic?
A: It may violate contrast and reduce clarity for low-vision users. - Q: Recommended hover fade approach?
A: Animate opacity modestly and keep text contrast acceptable.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.