How can we align our image to center? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can we align our image to center?

<img src=" " align="center"/> why this code format is not working

21st Sep 2017, 4:06 PM
Ruchika Pahari
Ruchika Pahari - avatar
4 Answers
+ 10
Put the <img> inside a <div> and set that div's CSS as "text-align:center;".
21st Sep 2017, 4:24 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
If you want to align image only by using html you can use: <p align="center"> <img src=" "/></p> or use css
21st Sep 2017, 4:13 PM
Lakshay
Lakshay - avatar
+ 3
The html attribute 'align' is to be avoided, as it's deprecated in Html5: you must use css instead ^^ Previous post answers for horizontal alignement... for vertical alignement, check this code: https://code.sololearn.com/WewcrAlN1m8k/?ref=app
22nd Sep 2017, 8:50 AM
visph
visph - avatar
+ 2
css for image parent{ text-align: center; }
21st Sep 2017, 4:09 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar