The Box Model and Spacing — Concept Check
Questions on The Box Model and Spacing. Every element is a box with content, padding, border and margin. Two rules — border-box sizing and single-direction margins — remove most sizing surprises.
Questions in this quiz
8 questions on The Box Model and Spacing — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer sets a div's width to 300px with 20px padding and 2px border. What is the rendered width if box-sizing is not set?
- A320px
- B300px
- C344px
- D340px
2.You notice that two vertically adjacent elements have a gap smaller than expected. What might be happening?
- AThe elements have no margin set.
- BMargin collapsing is reducing the gap.
- CPadding is being applied instead of margin.
- DThe border is hiding the gap.
3.A container has display: flex and its children have vertical margins. What happens to these margins?
- AThey are ignored.
- BThey collapse into a single margin.
- CThey do not collapse.
- DThey double in size.
4.A box with width: 50% and 10px padding overflows its parent. What could fix this?
- AReduce padding to 0.
- BIncrease parent width.
- CSet box-sizing: border-box.
- DUse margin instead of padding.
5.A developer sets a parent element's display to flow-root. What is the effect on its children's margins?
- AIncreases margin size.
- BPrevents margin collapsing.
- CHas no effect on margins.
- DApplies margin only to the parent.
6.What happens when you apply width: max-content to an element?
- AIt ignores padding and border.
- BIt expands to fit the content without wrapping.
- CIt becomes as wide as its parent.
- DIt shrinks to the smallest possible size.
7.Which CSS property prevents margin collapsing in a parent-child relationship?
- Aoverflow
- Bpadding
- Cborder
- Daspect-ratio
8.A long unbroken text string overflows its container. Which CSS property can help?
- Aoverflow-wrap: break-word
- Bwhite-space: nowrap
- Coverflow: visible
- Dtext-overflow: ellipsis