Get your own website Result Size: 625 x 534
x
 
<!DOCTYPE html>
<html>
<head>
<style>
img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
</style>
</head>
<body>
<h2>Center an Image</h2>
<p>To center an image, set left and right margin to auto, and make it into a block element.</p>
<img src="paris.jpg" alt="Paris" style="width:40%">
</body>
<!-- Mirrored from www.w3schools.com/css/tryit.asp?filename=trycss_align_image by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 14:29:23 GMT -->
</html>