title: Getting CSS to "float: right" and vertically center
body: <p>I am having some problems getting a small piece of text to be centered while floating next to an image.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css"&gt;
  img 
  {
  float:right;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;In the paragraph below, we have added an image with style &lt;b&gt;float:right&lt;/b&gt;. The result is that the image will float to the right in the paragraph.&lt;/p&gt;
  &lt;div&gt;
  &lt;img src="logocss.gif" width="95" height="84" /&gt;
  &lt;div style="position:relative; top: 20px;"&gt;
  This 
  &lt;/div&gt;
  &lt;div&gt;
  Other stuff...
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>(You can copy and paste this code into <a href="http://www.w3schools.com/CSS/tryit.asp?filename=trycss_float" rel="noreferrer">http://www.w3schools.com/CSS/tryit.asp?filename=trycss_float</a> to see it in action.</p>
  
  <p>What I would like is a way to vertically center the text while floating beside this image. and also not mess up text that comes after it. (as you can see, "Other Stuff..." is on top of "This")</p>
  
  <p>I would prefer a pure CSS approach(or possibly restructuring of divs and such) because this is just an example showing the problem. The application it is being used in is very complex and having it all go into a table would require quite a bit of work, and possibly wouldn't look right.  </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Ok, I have ripped out part of my asp.net generated page that shows the problem I am having. I realize the code is ugly and apologize. It was generated by machine</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css"&gt;
  img 
  {
      float:right;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;In the paragraph below, we have added an image with style &lt;b&gt;float:right&lt;/b&gt;. The result is that the image will float to the right in the paragraph.&lt;/p&gt;
  &lt;div&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;div style="line-height:84px;"&gt;
  &lt;img src="logocss.gif" width="95" height="84" /&gt;
  &lt;span&gt;This &lt;/span&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  Other stuff...
  &lt;br&gt;
  &lt;br&gt;
  Actual application:
  &lt;br&gt;
  &lt;div style="width:300px;"&gt;
    &lt;div style="width:300px;"&gt;
       &lt;input type="hidden"/&gt;
       &lt;table border="0" style="border-collapse:collapse;border-spacing:1px;"&gt;
         &lt;tr&gt;
          &lt;td style="width:250px;"&gt;&lt;div style="line-height: 50px;"&gt;
            &lt;input type="image" title="Calculate Field" src="logocss.gif" style="border-width:0px;float: right;" /&gt;&lt;span style="display:inline-block;color:Black;width:250px;"&gt;Email&lt;/span&gt;
             &lt;/div&gt;&lt;/td&gt;&lt;td style="width:350px;"&gt;&lt;table border="0"&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;input style="background-color:White;height:100%;width:300px;" /&gt;&lt;/td&gt;&lt;td style="width:300px;"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;td style="width:300px;"&gt;&lt;/td&gt;
         &lt;/tr&gt;&lt;tr style="height:0px;"&gt;
           &lt;td&gt;&lt;/td&gt;&lt;td colspan="2" style="width:300px;"&gt;&lt;span style="display:inline-block;height:0px;width:300px;"&gt;&lt;/span&gt;&lt;/td&gt;
         &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Sorry for big code but its a working example of my problem. I did the line height trick but it seems to have no effect here. Basically what I want is for the edit control to be vertically centered in the middle of the image(which is easy because of the table) and for the "Email" text to be vertically centered in the middle of the image. I can not make it work though in this arrangement. What am I doing wrong? </p>