0
How to align images to center?
13 ответов
+ 4
<center>
+ 3
With css, certainly...
But we need more information of your context to help you, because there are many solution possible according to it ^^
You could try to center the text of the container of your image ( if it's img tag element ), or use the margin property set with the "auto" value, as you can place it in a table-cell for control of the vertical alignment...
+ 2
@James Durand:
Yes, flexbox is another solution : I don't have this reflex, because I nerver get the time to dive in it... Maybe a day Oo ( I recently discover GUI's framework like tkinter for python, or android logic : I wonder if Flexbox is a kind of this sort of flow content managment, so I already started to acquire the comprehension of these logic and concept )
+ 1
For everyone suggesting the use of the align attribute on the img tag, this is a really bad idea. That attribute was deprecated way back in HTML 4 and marked obsolete in HTML 5. This means browsers no longer need to support it. You should ONLY be doing styling and layout via CSS, not HTML tags.
+ 1
@Megamind:
Read the answers before posting:
@James Durand already said that 'align' attribute of <img> tag is deprecated since Html4 and obsolete with Html5 ^^
+ 1
@Benj:
Less verbose, same result:
<html>
<head>
<title>Page Title</title>
<style>
body {
margin: 0;
text-align: center;
}
#i {
border: none;
border-radius: 50%;
width: 60px;
height: 60px;
}
</style>
</head>
<body>
<h4>|</h4>
<img src="https://www.sololearn.com/Icons/Courses/1024.png" id="i"/>
</body>
</html>
... But mostly, this is a very specific answer ;P
0
Flexbox is also a great option if you're targeting more modern browsers.
0
display: flex//////////////
justify-content: center///////////////////
align-items: center
- 4
<align></align>
- 4
For example
<img src="c:\collonspc\images\she.jpg" align="center"/>
- 4
<img src="#" align="center" height="500px" >
- 4
you can align centre or left by attribute command align= center or left
- 4
<font text-align="center" </font>