This is a very long text that will overflow the box and may require scrolling.
What will the user see in the browser?
medium
A. No scrollbars, content is cut off.
B. Scrollbars always visible even if not needed.
C. Scrollbars appear only if content overflows.
D. Content expands container size to fit all text.
Solution
Step 1: Understand overflow: auto; behavior
This value shows scrollbars only when content is bigger than the container.
Step 2: Analyze the content size
The text is longer than 100px width and height, so scrollbars will appear.
Final Answer:
Scrollbars appear only if content overflows. -> Option C
Quick Check:
auto shows scrollbars if needed [OK]
Hint: Auto means scrollbars only if content is too big [OK]
Common Mistakes:
Thinking auto always shows scrollbars
Assuming content resizes container
Confusing auto with hidden
4. You want to hide overflow content but accidentally wrote overflow: auto hidden; in your CSS. What will happen?
medium
A. The first value auto sets horizontal overflow, hidden sets vertical overflow.
B. The browser will ignore the entire overflow property.
C. The browser will show scrollbars always.
D. The CSS will cause a syntax error and not apply.
Solution
Step 1: Understand CSS overflow shorthand
overflow can take one or two values: first for horizontal, second for vertical overflow.
Step 2: Analyze two-value syntax
auto hidden is valid shorthand: horizontal = auto, vertical = hidden.
Final Answer:
The first value auto sets horizontal overflow, hidden sets vertical overflow. -> Option A
Quick Check:
Two-value overflow sets horizontal and vertical separately [OK]
Hint: Two values set horizontal and vertical overflow separately [OK]
Common Mistakes:
Thinking invalid syntax causes error
Assuming both values apply as one
Ignoring two-value overflow shorthand
5. You have a container with fixed width and height. You want to ensure that if content overflows horizontally, a scrollbar appears, but vertically overflow content is hidden without scrollbars. Which CSS is correct?
hard
A. overflow-x: scroll; overflow-y: hidden;
B. overflow-x: hidden; overflow-y: scroll;
C. overflow: scroll;
D. overflow: auto;
Solution
Step 1: Identify horizontal and vertical overflow needs
Horizontal overflow needs scrollbars, vertical overflow should hide content.
overflow: scroll; shows scrollbars both directions; overflow: auto; shows scrollbars only if needed both directions; overflow-x: hidden; overflow-y: scroll; reverses the requirement.
Final Answer:
overflow-x: scroll; overflow-y: hidden; -> Option A