spacer

home / experts / dhtml / column26
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Logo

IE4 / IE5 Rendering Differences
DIV element width


Author Intent

To display a nested DIV element using a percentage CSS width value.

In our example, the DIV is nested within a BLOCKQUOTE element. We want the DIV to be as wide (100%) as the BLOCKQUOTE display.

HTML

<BLOCKQUOTE>
<DIV STYLE="width:100%;color:white;background:blue">Some Content here</DIV>
</BLOCKQUOTE>

Your Browser Result (Live)

Some Content here

IE4 - IE5 Results (Illustrated)

IE4IE5


IE4 displays the DIV with a width inherited from the BODY of the page, not the BLOCKQUOTE element. Its left position corresponds to the BLOCKQUOTE left margin, but it runs off past the BLOCKQUOTE right margin.


In IE5, we get the expected rendering. The DIV is constrained by the margins set by BLOCKQUOTE.

The IE4 rendering is obviously confused. The DIV positioning is relative to the BLOCKQUOTE, but the width is not. It is a behavior problem fixed in IE5.

Solution

There is no sure-fire way to align the rendering behavior of the two browsers. However, to mimimize the possibility of the problem occuring, you can do one of the following:

General Note

In IE4, the width property is fairly problematic. You will find problems when applying it to the P and other block elements, as well. Always test your pages with both browser versions!

The IE4 width problem can also affect your text alignment, as we shall see on the next page.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: Oct 19, 1999
Revised: Oct 19, 1999

URL: http://www.webreference.com/dhtml/column26/width.html