Reputation: 9682
In a simple page where there is no overflow property specified, if the content overflows the window scrollbars appear.
Is the overflow: auto
or scroll
applied by the browser by default to the HTML or to the BODY element?
Example:
div {
height: 200vh;
border: 10px solid;
}
<div></div>
Upvotes: 4
Views: 2108
Reputation: 8210
overflow
is always defaulted to visible
on every element on which it is not specified.
The overflow property specifies whether to clip content, render scrollbars or just display content when it overflows its block level container.
Using the overflow property with a value different to visible (its default) will create a new block formatting context. This is technically necessary — if a float intersected with the scrolling element it would forcibly rewrap the content. The rewrap would happen after each scroll step, leading to a slow scrolling experience.
visible
is however, different from scroll
which enforces scrolling bars, even when no clipping occurs. Visible allows the content to be rendered outside the viewport, and allows scrolling bars to appear whenever content is overflowing the initial viewport.
In your example, body
is the reason for the scrollbars. Your body's content is rendered outside of the viewport (the div
inside it). Therefore, it automatically displays scrolling bars, specific to the body- the scrolling bars are being rendered on the viewport
instead of the element itself.
Example:
html, body {
width: 200px;
height: 200px;
}
div {
background-color: #F00;
width: 300px;
height: 300px;
}
<div></div>
Quote is from: https://developer.mozilla.org/nl/docs/Web/CSS/overflow
Upvotes: 3
Reputation: 7756
Its default value is overflow:visible;
The overflow property controls what happens to content that breaks outside of its bounds. here's what you can set it to:
Here are some good resources :
http://www.w3schools.com/jsref/prop_style_overflow.asp
https://developer.mozilla.org/en/docs/Web/CSS/overflow
Upvotes: 0