To horizontally center a block element (like div), use margin: auto;
Note: Using margin:auto will not work in IE8, unless a !DOCTYPE is declared.
In this example, the image is taller than the element containing it, and it is floated, so it overflows outside of its container:
Add a clearfix class with overflow: auto; to the containing element, to fix this problem:
This text is centered.