hasLayout Property

Gets a value that indicates whether the object has layout.

Syntax

HTMLN/A
Scripting[ sHasLayout = ] object.currentStyle.hasLayout

Possible Values

sHasLayoutBoolean that receives one of the following values.
false
Default. Object does not have layout.
true
Object has layout.

The property is read-only. The property has a default value of false. The Microsoft Cascading Style Sheets (CSS) extension is not inherited.

Remarks

The following table shows Cascading Style Sheets (CSS) properties and corresponding values that, if set, cause an element to have layout.

CSS propertyValue
displayinline-block
heightany value
floatleft or right
positionabsolute
widthany value
-ms-writing-modetb-rl
zoomany value

As of Microsoft Internet Explorer 6, when the !DOCTYPE declaration specifies strict standards compliance, inline elements ignore the width property and the height property. By setting the width property and the height property, you cannot cause the element to have layout.

By setting the contentEditable property to true, you can cause an element to have layout.

The following elements always have layout: BODY, IMG, INPUT, TABLE and TD.

Example

The following example shows how to use the hasLayout property to determine whether an object has layout.

<DIV ID="oWidthSet" STYLE="width:100%">
	DIV element A has its width set to 100%.</DIV>

<DIV ID="oNotSet">DIV element B is not positioned, 
	and neither its height nor width is set.</DIV>

<P>Which DIV element has layout?</P>

<BUTTON onclick="alert(oWidthSet.currentStyle.hasLayout)">
	DIV Element A</BUTTON>

<BUTTON onclick="alert(oNotSet.currentStyle.hasLayout)">
	DIV Element B</BUTTON>
This feature requires Microsoft Internet Explorer 5.5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this property.

Applies To

A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, currentStyle, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, hn, I, IMG, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, NOBR, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TD, TEXTAREA, TH, TT, U, UL, VAR, XMP, CSSCurrentStyleDeclaration Constructor
Tags :


Community Content

yecril
And OVERFLOW: HIDDEN also
DIV STYLE="OVERFLOW: HIDDEN" has layout as well.
Blocks with layout gain height even if they are empty:

no layout:
(empty)
layout by WIDTH: 20PX:
██
layout by OVERFLOW: HIDDEN:
███████████████████████████████████████████████████████
layout with FONT-SIZE: 1PX:
──
(The previous drawings are simulated, I am unable to get it right here)
This effect is unexpected and breaks the arrangement of blocks.

If an list has layout, list markers disappear.
If a list item has layout, it gets number 1.
If a list is within a block with layout, the list gets an extra empty line at the bottom.
Tags : contentbug

Page view tracker