Previous Message
Next Message

center images

Sent by David Kolar on 17 October 2003 23:11


Richard Hall wrote:
> ... thanks ... I'm wondering why text-align: center doesn't 
> work in IE, so 
> that you could put the margin auto for Gecko and text-align for IE?

It does work in IE. 

img {
	display: block;
	text-align: center;
	margin: 0 auto;
}

You would have to declare a width if this was not an image (which has its own intrinsic width). This
will center the image in both Gecko and IE (at least as far as I've tested it). This only works when
the image is set to display: block;. You can't align inline content, nor can you give inline content
'auto' margins. In the case above, text-align: center; is incorrectly centering the image block in
IE. That's what we need to do since IE does not support margin: auto;. 


Text-align applies to block elements and determines how inline content within the block element is
aligned. Thus, 

<div style="text-align:center;"><img ...></div>

....works in both browsers.

-David Kolar 

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Possibly related: