Help! , When i put align="center" On my img tag It doesn't shows in the middle | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Help! , When i put align="center" On my img tag It doesn't shows in the middle

<img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" align="center" width="150px" alt="">

24th Dec 2022, 8:27 PM
Kurei
Kurei - avatar
5 Answers
+ 4
Let me put this as simply as possible 🙆...Img is an inline tag, and, first it will have to be centered in a container ie. div, before you can use align = "center" on the tag itself.
25th Dec 2022, 5:04 PM
Sanjay Kamath
Sanjay Kamath - avatar
+ 3
<img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" style="display: block; margin-left:auto; margin-right:auto;" width="150px" alt="">
24th Dec 2022, 9:06 PM
JaScript
JaScript - avatar
+ 1
/<html> <head> <title> Profile </title> </head> <body> <h1 align="center"> Kurei </h1> <p align="center"> <strong>Editor</strong> </p> <img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" align="center" width="150px" alt=""> </body> </html>
24th Dec 2022, 9:15 PM
Kurei
Kurei - avatar
+ 1
JaScript With display: block; can be used simply: margin: auto; It's shorter. It is also fashionable to specify: display: inline-block; text-align: center;
24th Dec 2022, 9:58 PM
Knight
Knight - avatar
+ 1
You can put your img tag in the <p> tag and set the text-align: center for <p>🗿
26th Dec 2022, 12:29 AM
★$★
★$★ - avatar