Currently Empty: ₹0.00
CSS Overflow
CSS CODES & EXAMPLES
CSS Overflow
Learn how CSS controls content that is larger than its container. Understand visible content, hidden content, scrolling, text overflow, ellipsis, horizontal and vertical scrolling with practical examples.
01
Introduction to CSS Overflow
Control content that exceeds its container
The CSS overflow property controls what happens when
content is too large to fit inside an element’s defined dimensions.
Basic Syntax:
overflow: auto;
02
overflow: visible
Content remains visible outside the box
visible is the default value. Content that does not fit
inside the container can extend outside its boundaries.
This content is intentionally longer than the container.
With overflow: visible, the extra content
remains visible outside the box.
overflow-visible.css
.box {
width: 300px;
height: 100px;
overflow: visible;
}
03
overflow: hidden
Hide content outside the container
hidden clips content that exceeds the element’s
boundaries. No scrollbar is displayed.
overflow-hidden.css
04
overflow: scroll
Always provide scrollbars
With scroll, the browser provides scrolling mechanisms
even when the content does not currently require scrolling.
Scrollable Content
CSS overflow allows you to control large content inside a fixed area. Scroll this box to see more information.
This is useful for documentation panels, dashboards, code examples and compact user interfaces.
Additional content is included to demonstrate scrolling.
More content continues here for the scrolling example.
overflow-scroll.css
.box {
width: 300px;
height: 150px;
overflow: scroll;
}
05
overflow: auto
Show scrollbars only when necessary
auto is one of the most useful overflow values.
Scrollbars are displayed when the content exceeds the available space.
Auto Scrolling Area
This container automatically handles content that becomes larger than the available space.
This technique is commonly used in dashboards, chat boxes, sidebars and learning portals.
More content is available by scrolling.
overflow-auto.css
.box {
width: 300px;
height: 150px;
overflow: auto;
}
06
overflow-x
Control horizontal overflow
The overflow-x property controls what happens when
content exceeds the element horizontally.
HTML
CSS
JavaScript
WordPress
PHP
MySQL
overflow-x.css
.container {
overflow-x: auto;
overflow-y: hidden;
}
07
overflow-y
Control vertical overflow
The overflow-y property controls vertical content
that extends beyond the container.
Vertical Content
Lesson 1 — Introduction
Lesson 2 — HTML Basics
Lesson 3 — CSS Basics
Lesson 4 — CSS Selectors
Lesson 5 — CSS Box Model
Lesson 6 — CSS Display
Lesson 7 — CSS Position
Lesson 8 — CSS Z-Index
overflow-y.css
.container {
overflow-y: auto;
overflow-x: hidden;
}
08
Horizontal Scrolling
Build a responsive horizontal content area
01
HTML
Structure of webpages.
02
CSS
Style and layout.
03
JavaScript
Interactive webpages.
04
PHP
Server-side programming.
05
MySQL
Database management.
06
WordPress
Website management.
horizontal-scroll.css
.cards {
display: flex;
gap: 15px;
overflow-x: auto;
overflow-y: hidden;
}
.card {
min-width: 230px;
}
09
Vertical Scrolling
Scrollable content panels
CSS Course
Lessons
CSS Introduction
CSS Syntax
CSS Selectors
CSS Colors
CSS Backgrounds
CSS Borders
CSS Margins
CSS Padding
CSS Box Model
CSS Display
CSS Position
CSS Z-Index
CSS Overflow
CSS Float
CSS Flexbox
10
Scrollable Cards
Modern horizontal card layoutLearn HTML
Build the structure of modern webpages.
Learn CSS
Create professional website layouts.
Learn JavaScript
Add interaction to webpages.
Web Designing
Build complete responsive websites.
11
Text Overflow
Handle long text inside a fixed area
CSS provides properties such as text-overflow,
white-space and overflow to control
long single-line text.
This is a very long title that demonstrates how CSS can control
text that exceeds the available width of its container.
text-overflow.css
.title {
width: 300px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
12
text-overflow: ellipsis
Display three dots for clipped textCOURSE
Diploma in Computer Application with Advanced Practical Training
COURSE
Certificate in Tally Prime with GST and Accounting
COURSE
Professional Web Designing and Development Course
13
white-space
Control how text wraps
The white-space property controls whether text should
wrap onto a new line and how whitespace is handled.
This is a single long line that does not wrap automatically.
white-space.css
.text {
white-space: nowrap;
overflow: hidden;
}
14
overflow-wrap
Prevent long words from breaking layouts
overflow-wrap allows long words or strings to break
when they would otherwise overflow their container.
ThisIsAnExtremelyLongWordThatWouldNormallyCauseHorizontalOverflowOnASmallScreen
overflow-wrap.css
.text {
overflow-wrap: break-word;
}
15
Image Overflow
Prevent images from escaping their containers
IMAGE
Responsive Image Container
Images can be constrained using max-width and overflow rules.
image-overflow.css
img {
max-width: 100%;
height: auto;
}
.container {
overflow: hidden;
}
16
Container Overflow
Manage large content inside componentsCOURSE MODULE
Computer Fundamentals
Learn computer basics, hardware, software, operating systems, input and output devices, memory, storage and networking.
17
Responsive Overflow
Prevent horizontal page overflow on mobile
Responsive websites should avoid unwanted horizontal scrolling.
Use flexible widths, max-width, appropriate wrapping
and controlled overflow.
Responsive Content
Resize the browser to see how this component adapts to smaller screens.
responsive-overflow.css
* {
box-sizing: border-box;
}
img {
max-width: 100%;
}
.container {
max-width: 100%;
overflow-x: auto;
}
18
Common Overflow Problems
Fix unwanted scrolling and clipping01
Unexpected Horizontal Scroll
A fixed-width element may be wider than the viewport.
02
Content Gets Cut Off
Check whether a parent element uses
overflow: hidden.
03
Long Words Break Layout
Use overflow-wrap to handle very long strings.
04
Images Overflow
Use max-width: 100% for responsive images.
19
Live CSS Runner
Run a real CSS Overflow exampleLIVE PREVIEW
20
Practice Task
Test your CSS Overflow knowledge🎯 Your Challenge
Create a responsive course dashboard using CSS Overflow.
-
Create a vertical lesson list with
overflow-y. -
Create horizontal course cards with
overflow-x. -
Use
overflow: hiddenfor an image card. -
Create a long title using
text-overflow: ellipsis. -
Use
overflow-wrapfor long words. - Make the complete layout responsive.
21
CSS Overflow Quick Reference
Important properties at a glanceoverflow: visible
Content can extend outside the box.overflow: hidden
Extra content is clipped.overflow: scroll
Scrolling mechanisms are provided.overflow: auto
Scrolling is available when required.overflow-x
Controls horizontal overflow.overflow-y
Controls vertical overflow.text-overflow
Controls how clipped text is displayed.overflow-wrap
Allows long words to break.white-space
Controls text wrapping and whitespace.


