Navigator/Explorer Comparison


aligning text

how NN and IE handle aligning text

page 1 of 2


table of contents

centering text with colored divs

Centering text with the DIV element is trivial. The browsers respond predictably to using a DIV element with its ALIGN property set to CENTER. The differences come in when they render text in a DIV that has a colored background.

From the other chapters we found that a way to get NN4.7 and IE5.0 to render a colored box using a DIV element in the same way. We colored the background, set a WIDTH, and then used a border one pixel thick. We set the border color to the same color as the web page in order to make the border disappear in NN4.7. IE5.0 seems relatively unbothered by the one pixel wide border.

Below is the code for making a red box with some text in the manner described above.

<div style="background:red;
	width:2.5in;border-width:1px;
    border-color:white;">
      here is some text
</div>

we see in NN4.7:we see in IE5.0:
NN4.7 simple colored div box IE5.0 simple colored div box
we see in NN6.0: 
NN6.0 simple colored div box

Now let's add TEXT-ALIGN:CENTER to the style of the DIV.

we see in NN4.7:we see in IE5.0:
NN4.7 simple colored div box IE5.0 simple colored div box
we see in NN6.0: 
NN6.0 simple colored div box

We see that IE5.0 and NN6.0 aligned the text in the DIV element. NN4.7 aligned the entire DIV element but did not align the text relative to the DIV box at all.

Let's note here that removing the TEXT-ALIGN property from the DIV style and wrapping the above code in another DIV element with its ALIGN property set to CENTER gives the exact same effect in NN4.7. IE5.0 and NN6.0, however, will align the DIV to the center of the page as well as center the text within the DIV.

we see in IE5.0:we see in NN6.0:
IE5.0 simple colored div box NN6.0 simple colored div box

Finally, we can get NN4.7 to center the DIV, but again not the text inside the DIV by setting the ALIGN style property to CENTER. IE5.0 and NN6.0 will not respond to this code.

§
top


resources
Four Corners Effective Banners This site is dedicated to the study of all things banner-like, including: banners, click-through ratios, banner advertising, banner link exchanging, etc. You'll learn how to improve your banners and increase your site traffic.
Free Site Tools A webmaster's directory of free resources to help find about everything to build, maintain and promote your website. 1000+ Resources.
Free Webmaster Tools and Resources Your center for absolutely free high quality webmaster resources and tools to manage your web site. All utilities, programs and sites are carefully selected.
EZSearches.com Want access to free email, auctions, shopping bargains and more?  Try EZSearches.com
Akron Computer Repair A great computer repair company that does in-home visits or drop-off.
Cool Candle Shoppe Candles Place is a great site that if you're looking to purchase some great wax sticks, I'd go here.