+ 1
How to center Images
I'm trying to get an image centered, below u can find an example of a code I'm trying with a picture from google.com, and I added class="center" to img attribute and it ain't do it, also I've tried align="center" and it doesn't get centered!!! <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>This is a heading</h1> <p>My name is methos</p> <img src="https://www.google.com.eg/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="center" /> </body> </html> Appreciate your support
2 Answers
+ 11
you can use center tag to center the image
<center><img src="https://www.google.com.eg/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="center" /> </center>
or with css
.center {
   display: block;
   margin-left: auto;
   margin-right: auto;
   width: 50%;
}
+ 2
HTML :
<center>
<img src="image.png"/>
</center>
CSS :
img {
margin : 0 auto;
}