By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,395 Members | 1,882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,395 IT Pros & Developers. It's quick & easy.

CSS XHTML Firefox Right-Align Table

P: 3
I can center a table in any browser using:

<div style="text-align:center">
<table border="1" style="width: 50%; margin:0 auto">
<tr><td>etc</td></tr>
</table>
</div>

But I can't figure out how to right-align the table. I don't want to use deprecated align= in the <table> tag.

TIA for any clues.
Mar 24 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 100+
P: 1,892
I can center a table in any browser using:

<div style="text-align:center">
<table border="1" style="width: 50%; margin:0 auto">
<tr><td>etc</td></tr>
</table>
</div>

But I can't figure out how to right-align the table. I don't want to use deprecated align= in the <table> tag.

TIA for any clues.
Is the table centering? Try text-align: right in your div and get rid of the margin:0 auto in your table tag.
Mar 24 '07 #2

P: 3
Is the table centering? Try text-align: right in your div and get rid of the margin:0 auto in your table tag.
Yes, the centering is fine. I just can't get it to right-align. I tried what you suggested (below) but it won't right-align in Firefox:

<div style="text-align:right;">
<table border="1" style="width: 50%;">
<tr>
<td>cell</td>
<td>cell</td>
<td>cell</td>
</tr>
</table>
</div>

I can get it to right-align as below, but it only right-aligns in Firefox that way:

<div style="text-align:-moz-right;">
<table border="1" style="width: 50%;">
<tr>
<td>cell</td>
<td>cell</td>
<td>cell</td>
</tr>
</table>
</div>

The -moz-right is also flagged as invalid CSS in my code editor. The closest I've gotten so far is to try to display the table inline as below, but it makes the table look weird.

<div style="text-align:right;">
<table border="0" style="width: 50%; display:inline">
<tr>
<td>cell</td>
<td>cell</td>
<td>cell</td>
</tr>
</table>
</div>
Mar 24 '07 #3

drhowarddrfine
Expert 5K+
P: 7,435
Do this:
<div>
<table border="0" style="width: 50%; float:right">
<tr>
<td>cell</td>
<td>cell</td>
<td>cell</td>
</tr>
</table>
</div>
Mar 24 '07 #4

P: 3
Do this:
<div>
<table border="0" style="width: 50%; float:right">
<tr>
<td>cell</td>
<td>cell</td>
<td>cell</td>
</tr>
</table>
</div>
That did it, thanks!
Mar 25 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.