The text-align property in the CSS2
standard applies only to block level elements. So you can use it to
centre text within a p or div element,
for example, but you cannot use it to centre the p or
div itself.
Some old WWW browsers
(Internet Explorer version 5 for example) do centre block level elements
when text-align:center applies. But later browsers
implement the standard as it is written.
Eric Meyer* suggests centring block level elements this way:
px) for images, orexs or ems for fixed-size text%margin-left and margin-right
properties to autotext-align:center for old (non-compliant)
browsersHere is an example (from page 168 of a book by Eric Meyer*) used to centre an image:
<style type="text/css" media="screen">
body {text-align: center;} /* IE5.x workaround */
div#card {width: 575px; margin-left: auto; margin-right: auto;}
</style>