Page is a not externally linkable
Hagstrom - 10:11 am on Feb 8, 2004 (gmt 0)
For more time than I care to admit, I have struggled with finding out how to center images with CSS. Unfortunately the HTML specs [w3.org] only tell you how to center text with This solution works with Internet Explorer - leading people (like me) to believe that this is the right way to do it. But it's not.
"One of the goals of CSS is to provide an alternative to HTML extensions."
The reason is that images are not considered blocks even though they are quadrangular!
So you have to specify
display:block.This is not a problem for images, but if you use text-align:center to center a text-object your text will also be centered, so you have to have to nest two objects (e.g. a <p> within a <div> ) So the result is: <style> <img class="mycenter" src="....." height="...." width="....">
img.mycenter {margin-left:auto; margin-right:auto; display:block; text-align:center;}
</style>