Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

aligning text and button in one table cell 2

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
I have a the following code

Code:
<td>Text 1    <input type="submit" name="MyButton" value="Click Here"> </td>

I would like Text1 to be on the left side of the cell and the button on the right side of the cell.

I can do think by inserting another cell, but I was wondering if there is a way to do this in CSS?

Thanks
 
Try this:
Code:
<td><label>Text 1<input type="submit" name="Mybutton value="Click Here"/></label></td>

Let us know your results!

X
 
Howdy Xaqte,
I tried what you said and it still has them together.
I would like my output to look like this
Code:
Text 1                              buttonHere

This is how it is currently coming out
Code:
Text 1  buttonHere
 
HTML will always render muliple spaces as a single space, you could pad it with
Code:
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.


Keith
 
Howdy Audiopro,

I would rather add in another table with 2 <td> tags than add spaces.

I only know enough CSS to be dangerous, so I was wondering if this could be done in CSS.

Thanks again,
ksbigfoot
 
What about:
Code:
<td>Text 1<input style="margin-left: 150px;" type="submit" name="Mybutton value="Click Here"/></td>
 
Howdy Xaqte,

I am really looking for if my table is set at 100% and say I have one <td> tag, that I could align the Text 1 on the left and the button on the right.
I know I could just have two <td> tags and set the alignment on them, but I was curious.

Star to you as I think that is very valid way of doing it.

Thanks again,
ksbigfoot
 
I only suggest you add spaces for padding.
From a visitor's perspective, text which isn't close to it's associated field can be confusing.
Personally, I would go with using two cells but you seemed to be looking for the alternatives.

Keith
 
Howdy Audiopro,
The Text1 is not associated to the button I am referring to.
And I was just curious of how powerful CSS is and if it could do what I was thinking.

For a quick solution I did set up to <td> tags and have the left one align="left" and the right one align="right", then it pushes the text1 and button as far from each other as possible.

Thanks again,
ksbigfoot
 
You could do this:
Code:
<td><label>Text 1</label><input style="float: right;" type="submit" name="Mybutton" value="Click Here" /></td>
 
Howdy Vragabond,
I tried your way and it does separate the two items, but it sticks the button one line below the text. It would be nice to have them both on the same line.

Thanks
ksbigfoot
 
Ooops, of course it does:
Code:
<td><input style="float: right;" type="submit" name="Mybutton" value="Click Here" /><label>Text 1</label></td>
This will work.
 
Howdy Vragabond,

Sweet, works perfectly.
Star to you.
I don't understand why putting them in reverse order works, but it does.

thanks again,
ksbigfoot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top