This post explains how to center an image or text in HTML using CSS. The code example is available on GitHub in the Center-Image-Text-Div directory.
Centering An Image Vertically And Horizontally Within A Div
The method described here requires to know the size of the image. The HTML is the following:
<img id="myImg" src="SomeImg.jpg">
The CSS is the following: