Demo
The demo is available on a separate page
- HTML Code:
<p>There are no scrollbars on this page in sane browsers</p>
- CSS Code:
html, body, p {
margin: 0;
padding: 0;
}
body {
overflow: hidden;
}
p {
width: 5000px;
height: 5000px;
}
We have overflow
set to hidden
on ' element"><body>
element and inside of it we have a ' element"><p>
element that has very large dimensions set on it. What we see in sane browsers is that any excess window overflow caused by the ' element"><p>
is hidden and there are no scrollbars on the page.
In IE7 we just see the vertical one.
Yes, this sounds like a bug description, but if we look closer we will realize that ' element"><body>
does not have neither width
nor height
set on it, and for that reason, it would not hide any overflow. Why do sane browsers hide then? Section 11.1.1 of CSS 2.1 Spec states that if the value of overflow
on root element (' element"><html>
element in our case) is set to value visible
then user agents must apply the value of overflow
from ' element"><body>
element to the viewport.
What causes the problem here is that sane browsers by default set value visible
on ' element"><html>
element, while [judging by observation of behaviour]
IE7 has it as html { overflow-x: visible; overflow-y: scroll }
. Since the overflow
from ' element"><body>
element would transfer to viewport only when overflow
on ' element"><html>
element set to visible, there is no bug in IE, only unconventional default on ' element"><html>
element; as a side note: Opera 9.62 seems to miss this vital detail and transfers overflow
from ' element"><body>
all the time.