+ 1

Help! Maybe someone understands why my photo is not in the middle, I wrote there align="center"

<html> <body> <h1 align="center">Eric Glnjyan</h1> <p align="center"><strong>Programmer</strong></p> <img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" align= "center" width="150px"> </body> </html>

3rd Apr 2023, 7:57 PM
Eric Glnjyan
6 Answers
+ 3
<html> <head> <style> .center { text-align: center; } </style> </head> <body> <h1 class="center">Eric Glnjyan</h1> <p class="center"><strong>Programmer</strong></p> <img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" width="150px" class="center"> </body> </html>
4th Apr 2023, 11:09 PM
˹ᴅᴇᴠᴇʟᴏᴘᴇʀ ᴛᴧɴᴊᴇᴅ˼
˹ᴅᴇᴠᴇʟᴏᴘᴇʀ ᴛᴧɴᴊᴇᴅ˼ - avatar
+ 2
Although I'm not into website creation, I assume it is because **align** css property is used on text only. Therefore, you can put an html image inside a paragraph, and align a paragraph, which ideally will cause an image to move as well. However, there are other properties which will allow you to align text & images, don't hesitate to look them up
3rd Apr 2023, 8:01 PM
Lamron
Lamron - avatar
+ 2
Lamron <html> <body> <h1 align="center">Eric Glnjyan</h1> <p align="center"><strong>Programmer</strong></p> <center><img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" width="150px"></center> </body> </html> Looked on the Internet and found a new way for me. Instead of (align="center") the entire paragraph was written in (<center>......</center>) Thanks for your help ;)
3rd Apr 2023, 8:20 PM
Eric Glnjyan
+ 1
use margin and padding instead to center it
4th Apr 2023, 7:23 PM
Vinome
Vinome - avatar
+ 1
The align attribute is not recommended to use in HTML5, and it doesn't work with img elements when you set them to a value of "center". Instead, you can achieve the desired result by using CSS. Here's one way to center your image using CSS: <html> <head> <style> .center { display: block; margin: auto; } </style> </head> <body> <h1 align="center">Eric Glnjyan</h1> <p align="center"><strong>Programmer</strong></p> <img src="https://cdn2.iconfinder.com/data/icons/avatars-99/62/avatar-370-456322-512.png" class="center" width="150px"> </body> </html> Here we have defined a class called "center" in the CSS. We're using the display: block; property to make the image a block element so that we can center it, and then using margin: auto; to center the image horizontally. We then apply this class to the img element. This should center your image on the page.
5th Apr 2023, 2:16 AM
Z3ro