Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right aligning one column and left aligning the other, within one table

I have created a html table with 2 columns. I want the first column containing text to be right aligned, but i want the second column to stay left aligned as it contains check boxes. For presentation it would look, but ive no idea. I have tried creating a td class="column1" then text-align: right; in the CSS but no luck.

Any ideas would be greatly appreciated.

HTML

<td class="column1">Retrieve Logs:</td>
<td class="column2"><input type=checkbox name="getcamlogs" checked="checked"></td>

CSS

td.column1 {
   text-align: right;
}
like image 713
smurf Avatar asked Sep 02 '11 09:09

smurf


People also ask

Can you left align and right align on the same line?

Applying separate right and left alignment to the same line of text is impossible in Word; the format goes with the entire line. Usually, when you need that kind of arrangement, you might insert a table with two or more cells and apply the alignments to the cells.

How do I align left and right in Word table?

Go to the Layout tab and you will find there's an Alignment toolbox there. The Alignment toolbox has nine buttons for aligning text in a table in Microsoft Word. From left to right, and top to bottom, the buttons let you align text to the right, and top, center and top, and left and top.

How will you align a table to the right or left?

To allow text to flow around the table, use ALIGN=LEFT to position the table at the left margin, with text flowing around its right handside, or use ALIGN=RIGHT to position the table at the right margin, with text flowing around its left handside.


1 Answers

Here you go, this should work :)

<style>
    #mytable {width:500px; margin:0 auto;}
    #mytable td {width:250px;}
    #mytable .left {text-align:right; background:#333;}
    #mytable .right {text-align:left; background:#666;}
</style>

<table id="mytable">
    <tr>
        <td class="left">1</td>
        <td class="right">2</td>
    </tr>   
</table>
like image 188
Graeme Leighfield Avatar answered Nov 10 '22 05:11

Graeme Leighfield