How to Center an Image in CSS

For beginners it’s a big question how you will center an image using CSS.

If you’ve been coding HTML for a ling time, you may probably know the HTML tag to center an image.

Long time ago, people center different objects using <center> tag.

But due to some modernization in HTML and CSS. The best way to center an image using CSS is the code below.

Keep in mind that you need to declare clear: both to clear any floats that are present before the image that you want to align to center.