Search code examples
htmlcssvertical-alignment

Text pushed down after inserting images - need to vertically align text


JS FIDDLE: http://jsfiddle.net/nick55555/7tfca64y/

I probably have a situation very easy to solve but cant work out how to do it. I have a simple div with some text inside, which was vertically in the centre, but when I inserted an image into the same div, the text is now lower than it was originally. How can I make the text the same vertical height as it was before i inserted the images? the images are vertically aligned perfectly but the text isn't...

  #header_Bi {
    height: 39px;
    width: 748px;
    margin: 0;
    float: left;
    border-left: 1px solid #191919;
    border-right: 1px solid #191919;
    border-bottom: 1px solid #191919;
    font-family: arial, verdana, helvetica, sans-serif;
    font-size: 15px;
    color: #fff;
    font-weight: 100;
    text-transform: uppercase;
    background: #2c2c2c;
    text-align: center;
  }
  #header_Bi1 {
    height: auto;
    width: auto;
    margin-top: 10px;
  }
<div id="header_Bi">
  <div id="header_Bi1">
    <img src="../images/youtube_tiny.jpg" width="20" height="20" alt="youtube_tiny">
    <img src="../images/twitter_tiny.jpg" width="20" height="20" alt="twitter_tiny">
    <img src="../images/facebook_tiny.jpg" width="20" height="20" alt="facebook_tiny">
    <img src="../images/google_plus_tiny.jpg" width="20" height="20" alt="google_plus_tiny">SALES &amp; ADVICE EMAIL HERE</div>
</div>


Solution

  • If you want to align the text in the middle with the images, add #header_Bi1 img { vertical-align:middle;} to your css