| Inherited | Initial | Version |
|---|---|---|
| No | visible |
CSS2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.5+ | CH2+ |
|---|---|---|---|---|
| Buggy | Full | Full | Buggy | Full |
Syntax
Description
This property specifies the behavior that occurs when an element’s content overflows the element’s box.
The default behavior is to make the overflowing content visible, but it can be changed so that the content is clipped to the confines of the element’s box, optionally providing a mechanism for scrolling the content.
If the overflow property
is applied to the body or html
elements in an HTML document, the user agent may apply it to the viewport.
This does not apply to XHTML, though.
If a scrollbar needs to be provided, the user agent should insert it between the element’s outer padding edge and its inner border edge. The space occupied by the scrollbar should be subtracted (by the user agent) from the computed width or height, so that the inner border edge is preserved.
Boxes with an
overflow value other than visible
will expand vertically to enclose any floated descendant
boxes.
Margins will never collapse for a box with an
overflow value other than
visible.
Note that CSS3 defines the overflow-x and
overflow-y properties which allow for independent
control of the vertical and horizontal scrollbars.
Example
This style rule makes the
pre element type in HTML generate a fixed-sized box
with visible scrollbars:
pre {
width: 40em;
height: 20em;
overflow: scroll;
}
Example
This style rule makes the
pre element type in HTML generate a fixed-sized box
with the horizontal scrollbar hidden:
pre {
width: 40em;
height: 20em;
overflow:auto;
overflow-x:hidden;
}
Value
autoThe behavior of
autoisn’t specified in any detail in the CSS2.1 specification. In existing implementations it provides scrollbar(s) when necessary, but it doesn’t show scrollbars unless the content overflows the element’s box.hiddenhiddencauses content that overflows the element’s box to be clipped. No scrolling mechanism will be provided, so the overflow will be invisible and inaccessible.scrollscrollclips overflowing content, just likehidden, but provides a scrolling mechanism so that the overflow can be accessed. This scrolling mechanism is present whether the content overflows the element’s box or not, to prevent it from appearing and disappearing in a dynamic layout. When the output medium isprint, this value allows overflowing content to be printed (as if the value werevisible).visiblevisibleallows overflowing content to be visible. It will be rendered outside the element’s box, and may thus overlap other content.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Buggy | Buggy | Buggy | Buggy | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Buggy | Buggy | Full |
Internet Explorer for Windows versions up to and including 6:
- will not apply a value specified for the
bodyelement to the viewport, if the computed value for thehtmlelement isvisible - will increase the width and height of the element when the value
is specified as
visible, instead of rendering the overflow outside the element’s box; if the value isauto,hidden, orscroll, and the element’s width is specified asauto, the width will increase to avoid overflow
In Internet Explorer for Windows versions up to and including 7:
- a relatively positioned child of an element whose
overflowvalue isautoorscrollwill behave as if the position were specified asfixed; ifoverflowishidden, a relatively positioned element will be visible if the generated box lies outside the parent’s box - the value
inheritis unsupported
In Internet Explorer for Windows version 7, the values
auto, hidden, and
scroll cause an element to gain a layout.
Internet Explorer version 8 has
a variety of bugs when overflow is combined with
max-width or max-height and you can
find a series of test cases documented at the Hilbrand Edskes site.
Firefox versions up to
and including 3.5 apply overflow to table row groups
(although we have not marked this as buggy behavior in the compatibility
matrix).
The CSS3 overflow-x and
overflow-y properties are partially supported in
Internet Explorer for windows versions 5 and 6 and fully supported in
Internet Explorer versions 7 & 8. Safari 3+, Chrome 2+, Firefox 2+ and
Opera 9.5+ all support these properties.
Opera versions 9.5 and 10
exhibit a bug where a positioned parent container set to
overflow other than visible, that
also has an absolutely positioned child element will cause a scrollbar to
also appear on the viewport should that child’s top
position be greater than the viewport’s height.
User-contributed notes
- ID:
- #8
- Date:
- Sat, 02 Apr 2011 09:13:17 GMT
The padding bottom on an element set with overflow:auto (or scroll) is ignored in IE8.
http://www.sitepoint.com/forums/css-53/ie-padding-bottom-ignored-747438.html
http://www.sitepoint.com/forums/showthread.php?p=4572421&posted=1#post4572421
- ID:
- #7
- Date:
- Thu, 10 Feb 2011 19:37:22 GMT
FF has a bug using overflow on fieldset elements
https://bugzilla.mozilla.org/show_bug.cgi?id=261037
- ID:
- #5
- Date:
- Thu, 02 Apr 2009 19:53:09 GMT
IE7 scrollbar bug solution = "overflow:auto" + "overflow-y:hidden". See "Overflow:auto issue in IE7" in forum.