0
How to center an image in HTML ?
recently I am just working on my blog and I have got a problem in img tag I want to center image in HTML I know it's possible if I add css but I need an alternative so I can only use HTML
4 Answers
+ 4
Even though you can use center attribute to centerize an image, it's not the advisable method.
And many styling attribute in html including center attribute are going to deprecated soon, means any time your html styling attributes are not going to work on new browsers soon.
To style a html page, it's better to use css.
+ 3
Frey yes, it works. But it will not work in new browsers soon.
Please read this https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center
"Deprecated
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time."
So why not use css, which is working always.
0
CalviŐ˛ thanks well <center> </center> alway works out
0
You can do that, by making the image element display as a block,
The default display of an image element or the image element is display:inline;
You can try
img{
display: inline-block;
margin-left: auto;
margin-right: auto;
}