overflow Attribute | overflow Property

Internet Development Index

Sets or retrieves a value indicating how to manage the content of the object when the content exceeds the height or width of the object.

What's New for Microsoft® Internet Explorer 6

When you use the !DOCTYPE declaration to specify standards-compliant mode, this property applies to the html object.

Syntax

HTML { overflow : sOverflow }
Scriptingobject.style.overflow [ = sOverflow ]

Possible Values

sOverflowString that specifies or receives one of the following values.
visibleDefault. Content is not clipped and scroll bars are not added.
scrollContent is clipped and scroll bars are added, even if the content does not exceed the dimensions of the object.
hiddenContent that exceeds the dimensions of the object is not shown.
autoContent is clipped and scrolling is added only when necessary.

The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of visible for all objects with the exception of TEXTAREA which has a default value of auto. The Cascading Style Sheets (CSS) attribute is not inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

Remarks

The default value for the body element is auto.

Setting the overflow property to hidden on a textArea object hides its scroll bars.

Setting the overflow property to visible causes the content to clip to the size of the window or frame that contains the object.

This property is available on the Macintosh platform as of Internet Explorer 5.

  With Internet Explorer 6 and later, when you use the !DOCTYPE declaration to specify standards-compliant mode, this property applies to the html object.

Examples

The following examples use the overflow attribute and the overflow property to manage content of the object.

This example uses an inline style to automatically adjust itself to overflowing content when the page is loaded.

<DIV ID=oDiv STYLE="width: 200px; height: 200px; overflow: auto;">
:
</DIV>

This example allows the user to dynamically change the overflow property of a div object by choosing one of the possible overflow values from a select object.

<SCRIPT>
function SetOverflow(o, sValue)
{
o.style.overflow = sValue;
}
</SCRIPT>
<DIV ID="div1"
STYLE="font-size:18pt;background-color:yellow;height:50px;width:75px">
The quick brown fox jumped over the lazy dog.
</DIV>
<SELECT onchange="SetOverflow(div1,
this.options[this.selectedIndex].text)">
<OPTION SELECTED>visible
<OPTION>scroll
<OPTION>hidden
<OPTION>auto
</SELECT>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

This property is defined in Cascading Style Sheets (CSS), Level 2 (CSS2) Non-Microsoft link.

Applies To

A, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLOCKQUOTE, BODY, CENTER, CITE, CODE, COL, COLGROUP, currentStyle, CUSTOM, DD, defaults, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, HTML, hn, I, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MENU, OL, P, PLAINTEXT, PRE, Q, RT, RUBY, runtimeStyle, S, SAMP, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TEXTAREA, TT, U, UL, VAR, XMP

See Also

CSS Enhancements in Internet Explorer 6, overflowX, overflowY, position