6 replies [Last post]
davidklonski
Offline
newbie
Last seen: 19 years 2 days ago
Joined: 2004-03-30
Posts: 5
Points: 0

Hello

I am trying to display a table with 3 cells.
The 1st cell should be align to the left and the 2nd and 3rd cells should be aligned to the right and be adjacent to each other.

The output of the following code shows the the 2nd and 3rd cells have a space between them.
How do I make them both stick to the right of the table, one after the other?

Here is my code:

<html>
<body>
 <table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
   <form name="XXX" method="get">
    <td align="left" nowrap>text on left</td>
    <td align="right" nowrap>text on right</td>
    <td align="right">
     <select name="select">
      <option value="1"selected>1</option>
      <option value="2">2</option>
      <option value="3">3</option>
     </select>
    </td>
   </form>
  </tr>
 </table>
</body>
</html>

thanks in advance

co2
co2's picture
Offline
Leader
UK
Last seen: 14 years 50 weeks ago
UK
Joined: 2003-09-17
Posts: 721
Points: 0

aligning text within a table

I don't quite understand where the space is occurring for you (have tested the code and it seems fine). One thing you could try is wrap the form tag around the table tags instead of around the <tr> tag (in other words, encompass the whole table within the form tag).

Which browser are you viewing in? Also, can you post a screenshot of the problem?

The next sentence is true. The previous sentence is false. Discuss...

davidklonski
Offline
newbie
Last seen: 19 years 2 days ago
Joined: 2004-03-30
Posts: 5
Points: 0

aligning text within a table

I am using IE6.0
I am attaching a screenshot of the table.

I would like the 'text on right' cell to be aligned to the right nex to the 'select' cell

right now the 'text on right' cell is somewhere in the middle

co2
co2's picture
Offline
Leader
UK
Last seen: 14 years 50 weeks ago
UK
Joined: 2003-09-17
Posts: 721
Points: 0

aligning text within a table

Try this code:

 <html> 
 <body>
   <form name="XXX" method="get">
 <table width="100%" border="1" cellspacing="0" cellpadding="0"> 
  <tr> 
 
   <td align="left" nowrap>text on left</td> 
   <td align="right"> 
   <select name="select"> 
    <option value="1"selected>1</option> 
    <option value="2">2</option> 
    <option value="3">3</option> 
   </select> 
   </td>
   <td align="right" nowrap>text on right</td> 

  </tr> 
 </table>
   </form> 

 </body> 
 </html> 

The next sentence is true. The previous sentence is false. Discuss...

davidklonski
Offline
newbie
Last seen: 19 years 2 days ago
Joined: 2004-03-30
Posts: 5
Points: 0

aligning text within a table

this is not what I had in mind.

Now the <select> and the 'text on right' are switched

co2
co2's picture
Offline
Leader
UK
Last seen: 14 years 50 weeks ago
UK
Joined: 2003-09-17
Posts: 721
Points: 0

aligning text within a table

Confusion reigns! Do you mean to have them on top of each other:

+----------------------+------------------------+
|Text on Left          |          Text on Right |
+----------------------+------------------------+
|                                    Select [ ] |
+----------------------+------------------------+

If not, can you give an example! (Sorry for any misunderstanding Wink )

The next sentence is true. The previous sentence is false. Discuss...

davidklonski
Offline
newbie
Last seen: 19 years 2 days ago
Joined: 2004-03-30
Posts: 5
Points: 0

aligning text within a table

here is what I mean:

+----------------------+--------------------------------+------------+
|Text on Left | Text on Right | Select [ ] |
+----------------------+--------------------------------+------------+