New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
Why does a 300px box render wider than 300px the moment I add padding?
What you'll have at the end
Every box in the layout keeps the width you typed, no matter its padding or border
You need
A layout with at least one box, such as a card or an input, that needs to keep an exact width even after you add padding or a border, plus a stylesheet you can edit before your other rules run.
Not covered
This does not cover the gap margin collapse leaves between stacked elements, or choosing Flexbox over Grid for the layout itself; it only covers whether a declared width survives padding and border.
Checked 20 Aug 2026
Part of the CSS cookbook