+ 3

How to align an image to the center of the page?

I want to put an image at the center of my website. How do I do that? Because when I try, nothing happens Here's an example: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <img align="center" src="https://images.indianexpress.com/2017/03/books_thinkstock_759.jpg" alt="A book" /> </body> </html>

11th Jan 2019, 7:38 PM
Gustavo Matias
Gustavo Matias - avatar
6 ответов
+ 2
A few ways you can do this. Whatever you do you should probably wrap it in div tags. Look at adding auto left-right margins and using 50% top margin with translate y -50% You can also use display table and table cell to vertically align elements, Also you can do this with both flex and grid. Also DO NOT use <center> it's a non-supported tag in HTML 5 and may be removed / stop working in any browser with no notification.
13th Jan 2019, 9:27 AM
James Filby
James Filby - avatar
+ 6
Using align center on images won't work. IF you want to use it then center a div or a p and place the img inside of it. <div align="center"><img></div>
13th Jan 2019, 10:04 AM
Seniru
Seniru - avatar
11th Jan 2019, 8:06 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 2
Also DO NOT use <center> it's a non-supported tag in HTML 5 and may be removed / stop working in any browser with no notification.
13th Jan 2019, 10:20 AM
James Filby
James Filby - avatar
+ 2
Try doing that in CSS.
13th Jan 2019, 3:12 PM
Oscar Ofoetey Denfu
0
Use center tag if you want to align it in center or use div element
12th Jan 2019, 5:13 PM
Amresh
Amresh - avatar