align textbox in table cell

Lets say I have a table cell with some text, and two textboxes.
I'm trying to get the text and the first textbox to left align in the cell and the second textbox to right align in the cell, but keep them all on the same line.
Is there a way to do this without creating a whole new table inside the cell?

This code is close, but it drops the second textbox onto a new line.
<td>
   Words and Stuff
   <input class="txtright" type="text" size="7"">
   <input style="float:right" type="text" size="15">
</td>

Anybody know how to get this to work in css???
ppdocsAsked:
Who is Participating?
 
ZhaawZConnect With a Mentor Software DeveloperCommented:
Or you could try this:
<td>
   <div style="float:left;">Words and Stuff</div>
   <input style="float:left;" class="txtright" type="text" size="7">
   <input style="float:right;" type="text" size="15">
</td>


P.S. remove one quote at - size="7""
0
 
ZhaawZSoftware DeveloperCommented:
you could try to set margin-left for second input. Looks like this:

<td>
   Words and Stuff
   <input class="txtright" type="text" size="7"">
   <input style="float:right; margin-left:150px;" type="text" size="15">
</td>
0
 
dij8Connect With a Mentor Commented:
Or this:
<td>
   <input style="float:right" type="text" size="15">
   Words and Stuff
   <input class="txtright" type="text" size="7"">
</td>
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
sciwriterCommented:
<This code is close, but it drops the second textbox onto a new line.>

Likely because the numbers stated are just too tight for the browser to display on one line.  Adjust the numbers, there is no reason why this should not work, agreed, others?
0
 
ppdocsAuthor Commented:
Even if I expand my window it wont move up to the same line.  There is plenty of room. This should at least work in IE6.  You can use this to test:
<html>
<body>
<table width = "100%">
<tr>
<td>
<input type=text>words<input type=text style="float:right">
</td>
</tr>
</table>
</body>
</html>
0
 
GrandSchtroumpfCommented:
One sure thing is that you need to place your floating elements before your non-floated elements in the html.  That's what dij8's code does:
<td style="text-align:left;">
  <input type=text style="float:right"><input type=text>words
</td>

If you still don't have them on one line, try setting the width of the floated element:
<td style="text-align:left;">
  <input type=text style="float:right; width: 8em;"><input type=text>words
</td>
0
 
ppdocsAuthor Commented:
Doh!  I totally missed that!  Thanks Guys
0
All Courses

From novice to tech pro — start learning today.