How to center an image in a web page?

Below there is the css code to centering an image using css, which is an HTML5 valid method.

margin: 0px auto;display:block

If you apply the above css elements to an image, it will look like the below given code:

<img style="margin:0px auto;display:block" src="Image URL Here"/>;
Advertisements