Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

Why won't vertical-align: middle work? And yet, vertical-align: top does work.

Span{

vertical-align: middle;

}

<div> 

<img src="http://lorempixel.com/30/30/" alt="small img"/>

<span>Doesn't work.</span>

</div>

1 Answer

0 votes
by (106k points)

If you want to vertically align text next to an image you can apply the vertical-align to the image. As it is all in one line, son it’s really the image you want to be aligned, not the text.

<div>

<img style="vertical-align:middle" src="https://placehold.it/60x60">

<span style="">Works.</span>

</div>

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...