Internet Explorer and hasLayout

Even in standards mode Internet Explorer can still render a web page somewhat differently to the way other browsers do. Often this is due to Microsoft having invented their own concept of whether or not an element in the page hasLayout and rendering the page differently if that proprietary property is true to the way that it renders if it is false. Often the way of fixing IE to render the page properly just requires that we make hasLayout true for certain elements.

The problem comes in that there is no specific stylesheet command that triggers this proprietary setting. Instead the setting is dependent on the type of element and also on which styles are applied to the element. The following elements have hasLayout automatically set true: <body>, <table>, <tr>, <th>>, <td>, <img>, <hr>, <input>, <button>, <select>, <textarea>, <fieldset>, <legend>, <object>.

The following styles will also set hasLayout true:

The problem with most of these is that applying them will also have other effects on the appearance of the page. The presense or absense of most of these styles is therefore dependent on whether they are needed in order to position the parts of the page correctly for all browsers. Which of these that you should use to fix any layout problems with IE therefore depends on what exactly it is that you are trying to do.

Note that there are other tags and attributes that will trigger haslayout in Internet Ecplorer but those I have omitted are either deprecated or proprietary and so should therefore be avoided. Should you be unable to find one of the standard attributes to apply to fix a haslayout problem in Internet Explorer and you are not concerned about fixing a proprietary bug with a proprietary CSS command then adding zoom:1 to your CSS will trigger haslayout for that element and correct the error.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow