+ 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>
6 Answers
+ 4
The align-attribute is not supported on <img>.
https://www.w3resource.com/html/attributes/html-align-attribute.php
<center> is a deprecated tag and should not be used.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center
Alternative:
https://stackoverflow.com/questions/25462254/how-do-i-align-an-image-to-center#25462361
https://www.w3schools.com/howto/howto_css_image_center.asp
+ 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>
+ 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
+ 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 ;)
+ 1
use margin and padding instead to center it
+ 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.