freecoding.school100% FREE · NO SIGNUP
Grid CanyonISSUE #7 of 27

opacity · transparency

FlexboVSThe Float Phantom
Flexbo saysopacity makes an entire element (and its children) translucent, 0 to 1.

opacity:0.5 makes the whole element half-transparent — including all its children, which you can't undo on a child. For a translucent background only, use an rgba/hsla color. Opacity below 1 creates a new stacking context.

Power-ups you unlock

The Float Phantom attacks — common mistakes

Boss battleFade a whole card with opacity, then redo so only the background is translucent via rgba.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.a{opacity:.5}.b{background:rgba(179,136,255,.4)}div{padding:14px;color:#e6e0ff;margin:6px 0;background:#b388ff}</style></head><body style="background:#06040d;padding:20px"><div class="a">whole element faded</div><div class="b">only background translucent</div></body></html>
▶ Open the interactive comic issue
‹ Float · Clear · The Legacy LayoutVisibility · Hidden Vs Display None ›