Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image align='middle' in CSS

I was wondering if it is possible to align a picture using the align=middle style in CSS, not html.

<img alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/50px-Smiley.png" align="middle" />Text!
like image 952
Gelu Avatar asked Feb 14 '23 04:02

Gelu


2 Answers

Try this,

img{
  vertical-align:middle;
}

Use css property vertical-align:middle;

like image 87
Pranav C Balan Avatar answered Feb 24 '23 02:02

Pranav C Balan


you are using align attribute that in CSS is float : left; or float : right;

middle won't do anything, you only have option left or right.

For vertical-align, answers have already been given.

to center a single image on a line , you can use on parent : text-align:center;, image is an inline-box that reacts like text.

You can as well set image in display : block; and margin : auto;

like image 24
G-Cyrillus Avatar answered Feb 24 '23 02:02

G-Cyrillus