0
0
CSSmarkup~20 mins

Box model calculation in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Box Model Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Calculating total width of a box
Given a box with width: 200px, padding: 10px, border: 5px solid, and margin: 20px, what is the total width the box occupies horizontally in the normal flow (content + padding + border + margin)?
A270rem
B260px
C270px
D250px
Attempts:
2 left
💡 Hint
Remember to add padding, border, and margin on both sides (left and right) to the content width.
📝 Syntax
intermediate
2:00remaining
Box-sizing property effect
If a box has width: 300px, padding: 15px, border: 10px solid, and box-sizing: border-box, what is the actual width of the content area inside the box?
A320px
B300px
C270px
D250px
Attempts:
2 left
💡 Hint

With box-sizing: border-box, the width includes content, padding, and border.

rendering
advanced
2:00remaining
Visual effect of margin collapsing
Two vertical boxes each have margin-top: 20px and margin-bottom: 30px. When stacked vertically, what is the vertical space between them due to margin collapsing?
A30px
B50px
C20px
D0px
Attempts:
2 left
💡 Hint
Margins between vertical boxes collapse to the larger margin, not the sum.
selector
advanced
2:00remaining
Selecting only padding areas with CSS
Which CSS selector or property combination can be used to apply a background color to the content and padding areas of a box, excluding border?
AUse <code>background-clip: padding-box;</code>
BUse <code>background-clip: content-box;</code>
CUse <code>background-origin: border-box;</code>
DUse <code>background-clip: border-box;</code>
Attempts:
2 left
💡 Hint
The background-clip property controls where the background is painted.
accessibility
expert
3:00remaining
Ensuring accessible focus outline with box model
A button has padding: 1rem and border: 2px solid transparent. On focus, the border changes to 2px solid blue. Why is this approach better for accessibility than adding an outline?
ABecause outline is not visible on all browsers
BBecause border changes do not cause layout shift and are visible to keyboard users
CBecause padding is ignored by screen readers
DBecause transparent borders are ignored by assistive technologies
Attempts:
2 left
💡 Hint
Think about visual stability and keyboard navigation.