Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 450777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:54:10+00:00 2026-05-12T21:54:10+00:00

I am having some problems getting a small piece of text to be centered

  • 0

I am having some problems getting a small piece of text to be centered while floating next to an image.

<html>
<head>
<style type="text/css">
img 
{
float:right;
}
</style>
</head>
<body>
<p>In the paragraph below, we have added an image with style <b>float:right</b>. The result is that the image will float to the right in the paragraph.</p>
<div>
<img src="logocss.gif" width="95" height="84" />
<div style="position:relative; top: 20px;">
This 
</div>
<div>
Other stuff...
</body>
</html>

(You can copy and paste this code into http://www.w3schools.com/CSS/tryit.asp?filename=trycss_float to see it in action.

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”)

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.

UPDATE

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

<html>
<head>
<style type="text/css">
img 
{
    float:right;
}
</style>
</head>
<body>
<p>In the paragraph below, we have added an image with style <b>float:right</b>. The result is that the image will float to the right in the paragraph.</p>
<div>
<table>
<tr>
<td>
<div style="line-height:84px;">
<img src="logocss.gif" width="95" height="84" />
<span>This </span>
</div>
</td>
</tr>
</table>
Other stuff...
<br>
<br>
Actual application:
<br>
<div style="width:300px;">
  <div style="width:300px;">
     <input type="hidden"/>
     <table border="0" style="border-collapse:collapse;border-spacing:1px;">
       <tr>
        <td style="width:250px;"><div style="line-height: 50px;">
          <input type="image" title="Calculate Field" src="logocss.gif" style="border-width:0px;float: right;" /><span style="display:inline-block;color:Black;width:250px;">Email</span>
           </div></td><td style="width:350px;"><table border="0">
        <tr>
        <td><input style="background-color:White;height:100%;width:300px;" /></td><td style="width:300px;"></td></tr></table></td><td style="width:300px;"></td>
       </tr><tr style="height:0px;">
         <td></td><td colspan="2" style="width:300px;"><span style="display:inline-block;height:0px;width:300px;"></span></td>
       </tr>
</table>
</div>
</div>
</body>
</html>

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:54:10+00:00Added an answer on May 12, 2026 at 9:54 pm

    What about this? (note that the line-height value equals the image’s height):

    <html>
    <head>
    <style type="text/css">
    img 
    {
        float:right;
    }
    </style>
    </head>
    <body>
    <p>In the paragraph below, we have added an image with style <b>float:right</b>. The result is that the image will float to the right in the paragraph.</p>
    <div>
    <div style="text-align:right;line-height:84px;">
    <img src="logocss.gif" width="95" height="84" />
    This 
    </div>
    
    Other stuff...
    </body>
    </html>
    

    UPDATE:

    Considering the updated code, I came up with this:

    <div style="width:300px;">
      <div style="width:300px;">
         <input type="hidden"/>
         <table border="0" style="border-collapse:collapse;border-spacing:1px;">
           <tr>
            <td style="width:250px;"><div style="line-height: 84px; width:250px; text-align:right;">
              <input type="image" title="Calculate Field" src="logocss.gif" style="border-width:0px;float: right;" />Email
               </div></td><td style="width:350px;"><table border="0">
            <tr>
            <td><input style="background-color:White;height:100%;width:300px;" /></td><td style="width:300px;"></td></tr></table></td><td style="width:300px;"></td>
           </tr><tr style="height:0px;">
             <td></td><td colspan="2" style="width:300px;"><span style="display:inline-block;height:0px;width:300px;"></span></td>
           </tr>
    </table>
    </div>
    </div>
    

    I’m not saying it’s the best way to do it, but I tried not to modify your code too much.
    You don’t need to wrap the text in a span in my opinion.

    If you want to stick to using tables, then try looking at the valign=”middle” property of the td element : http://www.w3schools.com/TAGS/att_td_valign.asp
    But if you want to do that, you’ll have to separate the image from the text and put them in different tds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some problems getting some French text to convert to UTF8 so
Im having some problems getting the Sticky Footer to work on my site. If
I'm having some problems getting my object to gracefully fail out if an invalid
I'm having some problems getting ncurses' getch() to block. Default operation seems to be
I am having some problems getting my JS/JQ to fire in HTML5 page. Basically
I am having some problems getting a larger application with many table relationships working
I'm having some problems with getting the .getruntime.exec() to work properly. Here is the
Currently i am having some problems with getting some data out of a DataTable
I am having some problems getting this animation to execute. I have a feeling
i am having some problems with getting my form to submit. It doesnt seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.