+ 1
Centering image in HTML using CSS
Hello guys, I know that we can center and IMG tag by putting it within a phone tag then applying align attribute to it. e.g <p align="center" > This image is going to be centered <img src="url" width="240" />. </p> my question:. How can I achieve the same alignment above with CSS instead. <style> img{ ;} </style> ✊✊✊✊✊👍👍👍THANKS 👍👍👍✊✊✊ ENJOY THIS 🍓🍒🍓🍑🍏🍈🍇🍉🍊🍌🍍🌽🍆
8 ответов
+ 10
img
{
display :block;
margin : auto;
}
+ 10
vertical-align doesn't work for everybody
+ 8
vertical-align:middle;
+ 8
@Pegasus Using css not html
+ 7
use float: ;
+ 5
The text-align property specifies the horizontal alignment of text in an element. By default, text on your website is aligned to the left. However, at times you may require a different alignment.
text-align property values are as follows: left, right, center, and justify.
The vertical-align property sets an element's vertical alignment. Commonly used values are top, middle, and bottom.
The example below shows how to vertically align the text between the table.
+ 4
Nevermind I shall leave this instead.
https://www.sololearn.com/Course/CSS/?ref=app
+ 2
thanks all for the answers.
I am finally able to align the img tag using text-align in CSS.
this property is used to align almost anything else in HTML such as text, images, etc.