HTML img problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HTML img problem

If I add align attribute which have center value to img tag, then it doesn't work. Image don't align to center. But if I give the value right or left, it works, why?????

8th Oct 2019, 7:00 AM
Himanshu Rai
Himanshu Rai - avatar
6 Answers
+ 4
Maybe you can try wrapping the <img> within a <div> tag having `align` attribute set to 'center' as follows: <div align="center"><img src="path_to_file" /></div>
8th Oct 2019, 7:47 AM
Ipang
+ 1
Does it give you some kind of error? Are you sure you're spelling center correctly?
8th Oct 2019, 7:29 AM
Edijs Burger
Edijs Burger - avatar
+ 1
Hmm, this can work!
8th Oct 2019, 8:15 AM
Himanshu Rai
Himanshu Rai - avatar
+ 1
Glad to know it works 👍
8th Oct 2019, 8:18 AM
Ipang
+ 1
Thanks all for giving their suggestions
9th Oct 2019, 7:17 AM
Himanshu Rai
Himanshu Rai - avatar
0
Yes I'm spelling correctly, but giving the center value for align attribute in img tag does not working in HTML, while right and left values are working, you can check this.
8th Oct 2019, 7:34 AM
Himanshu Rai
Himanshu Rai - avatar