Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Handling Content Overflow in CSS | Mastering CSS Positioning
Advanced CSS Techniques
course content

Course Content

Advanced CSS Techniques

Advanced CSS Techniques

1. Getting Started with Advanced CSS
2. Mastering CSS Positioning
3. Creating Smooth Transitions in CSS
4. Advanced CSS Animations
5. Transforming Elements with CSS
6. Responsive Web Design in CSS
7. CSS Preprocessors and Sass

book
Handling Content Overflow in CSS

Let's consider how we can control the content overflow with the help of one property. Sometimes happens that we have the fixed width and height of the element. However, the inner content is much bigger than the available space. The overflow property controls the behavior of an element's content when it exceeds the height or width values explicitly set for the element.

  • visible - is the default value. The content overflows the element borders and stays visible;
  • scroll - The content overflows the element borders, and the scrollbar appears that allows a user to scroll both vertically and horizontally;
  • hidden - The content that overflows the element borders size is cut and not visible;
  • auto - works the same as scroll. However, the scrollbars appear only when the content overflows the element borders.

Note

The overflowing content does not affect the other elements' geometry.

visible

If the overflow property is not set, its default value is visible. It means that the content will be displayed outside the element's borders. In the example, the box's borders are highlighted in darkblue, and the box has fixed width and height properties.

html

index.html

css

index.css

copy

scroll

We can see the full element content using a scroll. Let's check the example:

html

index.html

css

index.css

copy

hidden

All overflow content will be hidden, and a user will never see it. Generally, it is helpful only when we need to develop some decorative effects.

html

index.html

css

index.css

copy
question mark

What does the overflow property do?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 12
We're sorry to hear that something went wrong. What happened?
some-alt