

While both overflow: hidden;
and height: auto;
are related to content overflow, there’s an important difference between them.
Let’s start with overflow: hidden;
.
Imagine we have something like this:
div {
height: 140px;
overflow: hidden;
}
In this case, the content inside the div
might be taller than 140px
. However, because we've set a fixed height of 140px
, the div
itself stays at that height. By using overflow: hidden;
, any content that exceeds the boundary of the div
is simply hidden from view—it’s cut off and not shown.
On the other hand, when you use height: auto;
, the height of the div
adjusts based on its content:
div {
height: auto;
}
This way, if the content inside the div
grows or shrinks, the height of the div
also grows or shrinks accordingly. No content is hidden, and everything is visible.
Since the div
expands to fit the content, there's no need for overflow: hidden;
.