(Of couse there will be horizontal scrollbars if the content is explicitly larger than one screen can show.
For example, this will happen with a 600 pixel wide table in a 200 pixel wide frame. This doesn't need an explanation.)
The horizontal scrollbars that appear in some browsers are caused by CSS bugs in those browsers, not by layout errors.J. Zeldman is talking about, imho, about IE5/MAC. In that configuration it is indeed a CSS bug, even two. A discussion and solution for the horizontal scrollbar bug with IE5/MAC. But I suspect that with IE6/WIN the DOCTYPE can be blamed. As we'll later find out, IE6 improper web standard implementation is to be blamed. Worth an investigation.
V No horizontal scrollbars X Horizontal scrollbars
| ¹ IE6/WIN | Compliance Mode | Quirks mode | ||
| CSS | No CSS | CSS | No CSS | |
| ² XHTML 1.1 | V | V | X | X |
| XHTML 1.0 Transitional | X | X | X | X |
| XHTML 1.0 Strict | X | X | X | X |
| HTML 4.01 Transitional | X | X | V | V |
| HTML 4.01 Strict | X | X | X | X |
¹ Opera 6, Netscape 6.2, Mozilla 1.2b showed no horizontal scrollbars, nor in Standard Compliance Mode nor in Quirks Mode.
² An XHTML1.1 document can begin with an XML declaration. Because IE6/WIN expects a DOCTYPE as the first line of code, the XML declaration is ignored and the document trips in Quirks Mode. In such case no horizontal scrollbars will show, but the nice thing is, you'll have a perfectly valid XHTML1.1 document.
Sigh, 20 different configurations, only 4 show no horizontal scrollbars if the document is trapped in frames. What to do with that? Internet Exploder is the most used browser in the world. This is a little disaster for web developers who like to code their documents according to W3C recommendations. One can only hope that the next version of IE will overcome this bug. Indeed, we can only hope, it's not a habit of M$ to take other's wishes into account.As you can see there are no horizontal scrollbars in IE6/WIN in HTML4.01 Quirks Mode and XHTML1.1 SC mode. CSS appears to have no effect on triggering the bug. Lucky for us there exist a couple of solutions, so called hacks (it remain bugs though), which can help us out here.
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
{overflow-y: sOverflow}
With scripting such as Javascript the vertical scrollbar is addressed as such:
object.style.overflowY [ = sOverflow ]sOverflow can have following values:
visible Default. Content is not clipped and scrollbars are not added.
Content is wrapped according to the size of the window or frame it resides in.
scroll Content is wrapped and scrollbars are added, even when the content does not exceed the dimensions of the object.
hidden Content exceeding the dimensions of the frame or window will not be shown.
auto Content is wrapped and scrollbars are only added if necessary.
<style type="text/css">
<!--
html {
overflow-x: hidden;
}
-->
</style>
If you use this code in your web document you'll see that the horizontal scrollbars have disappeared.
But the content that used to be visible thanks to the horizontal scrollbar lies now outside the viewing port of the frame or window.
Other values for the overflow-x property are not very helpful either.
We'll have to call upon the overflow-y property.
This snippet of code gives us exactly what we want; gone horizontal scrollbars and all content is visible.
<style type="text/css">
<!--
html {
overflow-x: hidden;
overflow-y: auto;
}
-->
</style>
The overflow-x and overflow-y eigenschappen are supported since IE5 and only on IE.
This is positive because it's a IE-only bug.
But it does raise the question about these properties being part of the official CSS-specification...
(Answer: they don't, only 'overflow' is)