How to Center an Image Vertically and Horizontally in HTML

It all depends on the size of the image. You need to set your top edge and left edge to 50%, then subtract half of the content size. So for example, my image below has a width of 300px, so I subtract 150px from the left edge by setting the left margin and do the same operation on the top margin.

<!DOCTYPE html>
<html>
<body>
	<div style="position:absolute;top:50%;margin-top:-179px;left:50%;margin-left:-150px;">
		<img src="image.png" width="300" height="358">
	</div>
</body>
</html>