How can I insert image in the centre in html? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can I insert image in the centre in html?

I am trying to make album of some photos so please help me how to insert any image in the centre right and left in HTML.

17th Jan 2018, 2:00 PM
Sinku🔰
Sinku🔰 - avatar
4 Answers
+ 4
Hi SA FUN, It completely depends on the layout of the rest of your page, but as a basic rule, you can change the image to display block and then set margin to 0 auto. So in your CSS: img { display: block; margin: 0 auto; }
17th Jan 2018, 2:07 PM
Dev Dreamer - YouTube
Dev Dreamer - YouTube - avatar
+ 4
it worked thanks
17th Jan 2018, 2:13 PM
Sinku🔰
Sinku🔰 - avatar
+ 3
I tried <center>tag. Didn't worked.
17th Jan 2018, 2:12 PM
Sinku🔰
Sinku🔰 - avatar
+ 2
@Jaydeep Khatri the <center> tag is NOT supported in html5. It is best to use CSS.
17th Jan 2018, 2:13 PM
Dev Dreamer - YouTube
Dev Dreamer - YouTube - avatar