Bick
Bick

Reputation: 18551

aligning text in html

I have the following rows in a css file

body {text-align: center;}
table {margin: 0 auto}

this causes to all text to be aligned to the middle. but in somse inner 's I want the text to be aligned right or left So I added

 <table style="text-align:right;"> 

and the text was still centered. what shoud I add ?

Upvotes: 0

Views: 78

Answers (4)

user1355061
user1355061

Reputation: 93

If you want only some of the text in the table to be right alignment.

then

<table>
<tr>
<td> Text </td>
<td style='text-align:right'>  This text is align to right </td>
<td style='text-align:left'> This text is align to the left </td>
</tr>
</table>

Upvotes: 1

Dagg Nabbit
Dagg Nabbit

Reputation: 76766

Your code actually works, it's just hard to tell in your example. Take a look at this fiddle:

http://jsfiddle.net/UzRdL/

Upvotes: 2

mariosk89
mariosk89

Reputation: 954

I guess the table is centered due to the parent div (body). I'll use a div with 100% width and align the text inside it to the right Or float the div or table to the rigth

Upvotes: 1

Er. Anurag Jain
Er. Anurag Jain

Reputation: 1793

Please add style="text-align:right" with td. i think it will be work.

thanks

Upvotes: 2

Related Questions