Learn how to center an image with CSS.
Read on how to do it in this tutorial: https://www.w3schools.com/howto/howto_css_image_center.asp
Centered image:
How To Center Images
Step 1) Add HTML:
Example
<img src="paris.jpg" alt="Paris" class="center">
Step 2) Add CSS:
To center an image, set left and right margin to auto
and make it into a block
element:
Example
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
Click me Note that it cannot be centered if the width is set to 100% (full-width).
Tip: Go to our CSS Images Tutorial to learn more about how to style images.