Help me Why this image code doesn't aligned to the center of the page ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help me Why this image code doesn't aligned to the center of the page ?

Align image to the center of the page <img src='a.jpg' align="center">

9th Apr 2020, 9:10 AM
Mik
Mik - avatar
7 Answers
+ 2
Koopa Scripter It mostly works for ascending compatibility and because html syntaxe is permissive, but it was retired from the specifications since html4, and it's strongly recommend to use css for presentation purposes... Anyway, browsers vendors are not expected to implement it, and support may change at any time ^^ Mik in fact <img> has two required attributes: href and alt... the second is often omitted, but that's not valid too in htm5... at worst, better to set alt with an empty string (alt=""), even if that's not really an advised practice ;P
9th Apr 2020, 9:58 AM
visph
visph - avatar
+ 1
You can do this instead: <center> <img src="a.jpg"/> </center>
9th Apr 2020, 9:16 AM
Koopa Scripter
Koopa Scripter - avatar
+ 1
<center> is not an html5 valid tag... much advised to apply css style "text-align:center" to the container, creating a new one if necessary ^^ The container must be of type block...
9th Apr 2020, 9:40 AM
visph
visph - avatar
+ 1
visph But it works
9th Apr 2020, 9:49 AM
Koopa Scripter
Koopa Scripter - avatar
+ 1
It mean img tag does't have other attribut then src?
9th Apr 2020, 9:51 AM
Mik
Mik - avatar
+ 1
Koopa Scripter yeh it work yr code but need to change other thing like width ... Color
9th Apr 2020, 9:54 AM
Mik
Mik - avatar
0
thinks to much frds
18th Sep 2021, 2:46 PM
Mik
Mik - avatar