0
0
CSSmarkup~20 mins

Overflow property in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Overflow Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does overflow: hidden; do?
You have a box with content that is bigger than the box size. What happens when you apply overflow: hidden; to the box?
CSS
<style>
.box {
  width: 10rem;
  height: 5rem;
  border: 1px solid black;
  overflow: hidden;
}
</style>
<div class="box">This text is very long and will not fit inside the box.</div>
AThe extra content outside the box is cut off and not visible.
BThe box expands to fit all the content inside.
CThe extra content is shown with a scrollbar inside the box.
DThe extra content is visible outside the box without any clipping.
Attempts:
2 left
💡 Hint
Think about what happens when you want to hide anything that doesn't fit inside a container.
📝 Syntax
intermediate
2:00remaining
Which CSS rule correctly adds a vertical scrollbar when content overflows?
You want a box to show a vertical scrollbar only if the content is taller than the box. Which CSS overflow property value should you use?
CSS
.box {
  width: 12rem;
  height: 6rem;
  border: 1px solid black;
  overflow-y: ???;
}
Ahidden
Bscroll
Cauto
Dvisible
Attempts:
2 left
💡 Hint
You want the scrollbar only when needed, not always visible.
rendering
advanced
2:00remaining
What will you see with overflow: visible; on a fixed-size box?
Consider this HTML and CSS. What is the visible result in the browser?
CSS
<style>
.container {
  width: 8rem;
  height: 4rem;
  border: 2px solid blue;
  overflow: visible;
}
</style>
<div class="container">
  <p>This text is very long and will overflow outside the box.</p>
</div>
AThe text is clipped and only visible inside the blue border.
BThe text overflows outside the blue border and is fully visible.
CA scrollbar appears inside the box to scroll the text.
DThe box expands to fit the entire text inside.
Attempts:
2 left
💡 Hint
Think about what happens when overflow is set to visible by default.
selector
advanced
2:00remaining
Which CSS selector targets only elements with overflow set to scroll?
You want to style only elements that have overflow: scroll; applied. Which selector will work?
A:overflow(scroll)
B.scrollable
C[overflow='scroll']
D[style*='overflow: scroll']
Attempts:
2 left
💡 Hint
Think about how to select elements by inline style attribute content.
accessibility
expert
3:00remaining
How to ensure keyboard users can scroll overflow content?
You have a box with overflow: auto; and scrollbars. What should you do to make sure keyboard users can scroll the content easily?
AAdd <code>tabindex="0"</code> to the box so it can receive keyboard focus.
BAdd <code>aria-hidden="true"</code> to hide the box from screen readers.
CUse <code>overflow: hidden;</code> to prevent scrolling.
DRemove all focus styles to avoid distraction.
Attempts:
2 left
💡 Hint
Think about how keyboard users navigate and interact with scrollable areas.