• 0
name Punditsdkoslkdosdkoskdo

How to Vertically align text next to an image?

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

   <img style="width:30px;height:30px">
   <span style="vertical-align:middle">Doesn't work.</span>

Actually, in this case it's quite simple: apply the vertical align to the image. Since it's all in one line, it's really the image you want aligned, not the text.


<!-- moved "vertical-align:middle" style from span to img -->
  <img style="vertical-align:middle" src="">
  <span style="">Works.</span>

Now you can use flexbox for this type of layout.

.box {
   display: flex;
<div class="box">
    <img src="">
    <span style="">Works.</span>
  • 1
Reply Report

Related Questions

Trending Tags