Centering Image | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Centering Image

How do you center an image in HTML? I tried a few different methods from tutorials and none worked :( Here's what I currently have: <img align = "middle" src Velvet_Vic.jpg height = "100px" width = "100px" />

20th Nov 2017, 6:05 AM
Bryan
Bryan - avatar
7 Answers
+ 7
I made the changes and the image was centered- thanks Calvin!
20th Nov 2017, 7:08 PM
Bryan
Bryan - avatar
+ 6
Autocorrect changed src to sex lol and the tutorial had middle oddly enough instead of the usual center. I will make those changes and see what happens though
20th Nov 2017, 3:11 PM
Bryan
Bryan - avatar
+ 4
let's check your code...
20th Nov 2017, 6:25 AM
Calviղ
Calviղ - avatar
+ 4
I posted the line of code pertaining to the image above in the edit!
20th Nov 2017, 7:08 AM
Bryan
Bryan - avatar
+ 3
There are several errors, Firstly you cannot align an image by setting align attribute on img tag, you need to set align attribute on img parent tag. Secondly there is no align="middle", it should be align="center". Double-check your tutorials. Thirdly the img link, sex Velvet_Vic.jpg is not the valid link, your img link should be in src attribute, please check your tutorials.
20th Nov 2017, 8:10 AM
Calviղ
Calviղ - avatar
+ 2
Yeah it's much easier to help provide an answer when you post a code.
20th Nov 2017, 7:05 AM
Andrew T$
Andrew T$ - avatar
+ 2
<img align = "middle" src ="path" />
23rd Nov 2017, 5:33 AM
TUYUK