|
||||||||||||||||||
aligning texthow NN and IE handle aligning text07/03/00page 1 of 1centering text with colored divsCentering text with the DIV element is trivial. Both 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.
Now let's add TEXT-ALIGN:CENTER to the style of the DIV.
We see that IE5.0 aligned the text in the DIV element. NN4.7 aligned the entire DIV element and 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, however, will align the DIV to the center of the page as well as center the text within the DIV.
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 will not respond to this code.
|
||||||||||||||||||