Assuming the browser window is 800px wide and 1rem = 16px.
medium
A. 400px wide
B. 720px wide
C. 800px wide
D. 50rem wide ignoring max-width
Solution
Step 1: Calculate 50rem in pixels
50rem x 16px = 800px, so width is 800px if no max-width applied.
Step 2: Calculate max-width 90% of window
90% of 800px = 720px, so max-width limits width to 720px.
Step 3: Compare width and max-width
Since 800px (width) is larger than 720px (max-width), the content area width becomes 720px.
Final Answer:
720px wide -> Option B
Quick Check:
Max-width limits width to 720px [OK]
Hint: Max-width limits width even if width is bigger [OK]
Common Mistakes:
Ignoring max-width and using width only
Confusing rem to px conversion
Not calculating percentage of window width
4. This CSS is meant to center the content area horizontally:
.content {
width: 600px;
margin: 0 0 auto;
}
Why does it fail to center?
medium
A. Because 'margin: 0 0 auto;' sets bottom margin, not horizontal margins
B. Because width must be in % to center
C. Because width is too large to center
D. Because margin shorthand is missing 'auto' for left and right
Solution
Step 1: Understand margin shorthand
Margin shorthand with three values means: top, horizontal (left and right), bottom. Here '0 0 auto' means top=0, left/right=0, bottom=auto.
Step 2: Check horizontal margins for centering
To center horizontally, left and right margins must be 'auto', but here they are 0, so no centering.
Final Answer:
Because margin shorthand is missing 'auto' for left and right -> Option D
Quick Check:
Horizontal margins must be auto to center [OK]
Hint: Use margin: 0 auto; to center horizontally [OK]
Common Mistakes:
Using margin: 0 0 auto instead of margin: 0 auto
Thinking width must be % to center
Assuming large width prevents centering
5. You want a content area that is centered, has a max width of 700px, padding of 1.5rem, and a subtle shadow. Which CSS snippet achieves this correctly?