Code has been added to clipboard!

The CSS Overflow Property

Reading time 2 min
Published Aug 8, 2017
Updated Oct 1, 2019

Defining overflow in CSS

By using the CSS overflow property, you can manipulate the element's behavior in cases when the content cannot fit within its borders. It is actually a shorthand for two CSS overflow subproperties:

  • overflow-x
  • overflow-y

Both of them can also be used separately:

Example
div {
    overflow-x: hidden;
}
Example
div {
    overflow-y: hidden;
}

CSS overflow syntax and property values

The syntax for overflow is similar to that of the other CSS shorthands – you need to write the values for both subproperties without actually typing their names:

overflow: overflow-x overflow-y;

overflow-x defines how left and right sides of a container react to overflowing content, and overflow-y; does the same for the top and bottom edges. If you only define one value, it will apply to both subproperties.

Both overflow-x and overflow-y take the same values:

Value Description
visible The default value. The content is not clipped and may overflow the padding box
hidden The content can be clipped, and the user can only scroll programmatically
clip The content can be clipped, and the user cannot scroll (even programmatically)
scroll The content can be clipped, but the user can scroll using a scrollbar in CSS
auto Element's behavior depends on the browser

Dealing with CSS text overflow

The CSS text-overflow property defines how the browser will inform the user about the presence of overflowed text content:

Example
div {
    text-overflow: ellipsis;
}

To use this property, you need to choose and define one out of three possible values:

text-overflow: value;

Value Description
clip The default value. The text is clipped at the edge of the container, even if it's the middle of the character/td>
ellipsis An ellipsis ('…') is shown at the end of the clipped text inside the container
string A specified string is shown at the end of the clipped text inside the container

Browser Support

Chrome
1+
Edge
12+
Firefox
7+
IE
6+
Opera
11+
Safari
1.3+

Mobile Browser Support

Chrome
18+
Firefox
7+
Opera
11+
Safari
All
Tutorial
CSS3 Features
Syntax
Classes
ID Selectors
Attribute Selectors
Stylesheets
Inline
Internal
External
Box Model
Children Selectors
Pseudo Classes
Pseudo Elements
Variables
Counters
Text
Fonts
Web Fonts
Backgrounds
Background Images
Colors
Gradients
Opacity / Transparency
Shadow Effects
Transitions
Tooltip
Transform
Animations
Layout — Display
Layout — Position
Layout — Float
Layout — Clear
Layout — Horizontal & Vertical Align
Multiple Columns
Introduction
Responsive Web Design — Viewport
Responsive Web Design — Grid View
Responsive Web Design — Media Queries
Responsive Web Design — Flexbox Layout
Responsive Web Design — Images
Responsive Web Design — Videos
Borders
Margin
Padding
Width
Height
Outline
Links
Lists
Tables
Dropdown Menu
Navigation Bar
Images
Image Gallery
Border Images
Forms
Rounded Corners
Buttons
Box-Sizing
Selector Reference
Pagination Examples
Code Examples
CSS3 Browser Support Reference
Functions Reference
Speech Module Reference
Units
Web Safe Font Combinations
Cheat Sheet
:hover
@font-face
@keyframes
@media
align-content
align-items
align-self
all
animation
backface-visibility
background
background-clip
background-color
background-image
background-origin
background-position
background-size
border
border-image
border-radius
border-style
box-shadow
box-sizing
color
columns
filter
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
font
font-family
font-size
font-size-adjust
font-stretch
font-style
font-weight
hanging-punctuation
justify-content
line-height
margin
offset
opacity
order
outline
overflow
padding
perspective
position
resize
tab-size
text-align
text-decoration
text-emphasis
text-transform
text-shadow
transform
transition-property
translate
vertical-align
word-break
word-wrap
z-index