467,910 Members | 1,699 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,910 developers. It's quick & easy.

CSS XHTML Firefox Right-Align Table

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
  • viewed: 10799
Share:
4 Replies
Expert 1GB
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
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 4TB
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
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.

Similar topics

32 posts views Thread by jp29 | last post: by
9 posts views Thread by James Pickering | last post: by
16 posts views Thread by Mcginkel | last post: by
23 posts views Thread by Gustaf | last post: by
2 posts views Thread by Eric Lindsay | last post: by
24 posts views Thread by Dan Jacobson | last post: by
1 post views Thread by Mellow Crow | last post: by
10 posts views Thread by Robert Huff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.