Centring Images Using CSS

While working on my latest theme, I wanted a way to centre images. CSS 2 doesn’t have any native way to centre align an image. But there is one way to force the image to be centred:

img.centred {display: block;margin-left: auto;margin-right: auto;}

This CSS code specifies that the image should be displayed as a block and the left and right margins are automatically sized, forcing the image to be centred.