| Inherited | Initial | Version |
|---|---|---|
| No | visible |
CSS2 |
| IE7+ | FF1+ | SA1.3+ | OP9.2+ |
|---|---|---|---|
| Full | Full | Full | 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.
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;
}
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 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.0 | 9.2 | 9.5 |
| Buggy | Buggy | Full | Full | Full | Full | Full | Full | Full | Full | 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.
Firefox versions up to and
including 2 apply overflow to table row
groups.
User-contributed notes
- ID:
- #5
- Date:
- Thu, 02 Apr 2009 19:53:09 GMT
- Status:
- This note has not yet been confirmed for accuracy and relevance.
IE7 scrollbar bug solution = "overflow:auto" + "overflow-y:hidden". See "Overflow:auto issue in IE7" in forum.
- ID:
- #4
- Date:
- Mon, 30 Mar 2009 19:31:40 GMT
- Status:
- This note has not yet been confirmed for accuracy and relevance.
You believe incorrectly - Opera 9 does support them.
- ID:
- #2
- Date:
- Fri, 28 Mar 2008 06:04:30 GMT
- Status:
- This note has not yet been confirmed for accuracy and relevance.
There is no mention of the overflow-x and overflow-y properties here.
AFAIK, they support all values of overflow, but only apply them horizontally or vertically. overflow-x and -y are part of the forthcoming CSS3 standard, and are already supported by most browsers (I believe Opera is yet to support it).
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.