wtf(css)layout you can see happening
← wtf(css)
Explain the wtf

Margin collapsing, and the margin that escapes

HardThe famous WTFsW02

The panel has margin-top: 40px. The 40px turned up ABOVE the card instead of inside it, and the card is now the wrong height. Nothing in the stylesheet gives the card a margin.

The yellow panel wants 40px of breathing room at the top of its card. The card is 400px wide and its child is 80px tall, so the card should be 400×120 with the panel 40px down from the top of the page's content box. What you get instead is a card that is exactly as tall as its panel, sitting 40px lower than it should. The margin left the building. Put the 40px back inside the card. The card's box must come out exactly 400×120, and it has to keep working when the panel's height changes.

Hint

The margin is not being ignored — it moved something. Which box did it move, and what would have had to be in its way to stop it?

Live preview800×600
Your stylesheet
checked in a real browser, four ways
The fixture — markup and base stylesheet

You cannot change either of these. They are what your selectors have to reach, and they are the same ones the judge renders.

<div class="page"><div class="card"><div class="inner"></div></div></div>
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #0b0b0f; color: #e8e8ef; font: 16px/1.4 system-ui, -apple-system, sans-serif; }
.page { width: 600px; padding: 20px; background: #16161d; }
.card { width: 400px; background: #22323f; }
.inner { height: 80px; margin-top: 40px; background: #ffd166; }