Previous Message
Next Message

Re: [css-d] trouble centering text in n6.2

Sent by Timothy Tolle on 25 January 2002 08:08

Joshua Usdavin wrote:

> I'm trying to center text below an image and within the width of the 
> image placed above.  My CSS

Short answer: your 'p' margins are wrong. Set them to look like this:
p {   margin: 0px auto 0px auto; }

Long answer: You're using 'text-align' inappropriately. You set 
'text-align: center'  as property of the body tag, thinking it would 
center all elements on the page, including the 'p' blocks. Text-align, 
however, only applies to inline elements-- that's text and images, for 
your purposes. When Netscape 6 (or Opera, or whatever) encounters the 
'p' tag, the 'text-align: left' overrides the body declaration, making 
all the text inside it move to the left. The p block itself does not get 

Adding auto margins to the left and right of the p block will make the 
whole block center on the page.

The fact that IE rendered it how you wanted only means IE was rendering 

Hope this helps.
Previous Message
Next Message

Possibly related: