CHAPTER 24
CSS Overflow
Learn how to control content that becomes larger than its container.
01. What is CSS Overflow?
Overflow happens when content is larger than the available space.
CSS provides overflow, overflow-x and overflow-y properties.
Common values include visible, hidden, scroll and auto.
02. Syntax
selector {
overflow: value;
}
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 300px;
height: 150px;
border: 2px solid #2563eb;
overflow: auto;
padding: 15px;
}
</style>
</head>
<body>
<div class="box">
<p>
AIFA Coding Lab provides practical learning.
This content is intentionally long so that
the container can demonstrate overflow behavior.
Students can learn HTML, CSS and JavaScript.
</p>
</div>
</body>
</html>
04. Important Points
✓
visible allows overflowing content to remain visible.
✓
hidden clips overflowing content.
✓
scroll always provides scrolling areas.
✓
auto adds scrolling when required.
✓
overflow-x and overflow-y control horizontal and vertical overflow separately.
05. Common Mistakes
⚠
Using overflow: hidden to hide content accidentally.
⚠
Creating horizontal scrolling on mobile pages.
⚠
Using fixed heights for content that can grow.
06. Real World Use
Overflow is useful for code editors, tables, cards, menus, scrollable panels and long content areas.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Create a Scroll Box
Create a 300px wide and 150px high box with enough text to require scrolling. Use overflow: auto.