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

text-align: right in Firefox

P: n/a
Hi!

When I put a table into a table and try to align it right, it works in IE
but not in Firefox.

Simplest code to reproduce:
<html>
<body>
<table style="width: 100%">
<tr>
<td style="width: 50%">
blabla
</td>
<td style="width: 50%; text-align:right;">
<table>
<tr><td>test</td></tr>
</table>
</td>
</tr>
</table>
</body>
</html>

How do I align it right "rightly". ;)

Regards, André

Jul 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Els
André Hänsel wrote:
Hi!

When I put a table into a table and try to align it right,
it works in IE but not in Firefox.

Simplest code to reproduce:
<html>
<body>
<table style="width: 100%">
<tr>
<td style="width: 50%">
blabla
</td>
<td style="width: 50%; text-align:right;">
<table>
<tr><td>test</td></tr>
</table>
</td>
</tr>
</table>
</body>
</html>

How do I align it right "rightly". ;)


table td table{float:right;}

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 21 '05 #2

P: n/a
"André Hänsel" <an***@webkr.de> wrote:
When I put a table into a table and try to align it right, it works in IE
but not in Firefox.
Usually when people describe a problem that way, it's in reality Firefox
that gets things right and IE wrong.
<td style="width: 50%; text-align:right;">
<table>
<tr><td>test</td></tr>
</table>
</td>
The text-align property affects, by CSS specifications, the alignment of
text lines inside the element. The inner table is a block element, so it is
not affected. The text-align property is inherited into the inner td so the
line ultimately gets aligned to the right, but only within its container,
the cell, and the width of the container is here just as much as needed for
it. IE, as so often, gets this wrong.
How do I align it right "rightly". ;)


Using float: right as suggested by Els would be the technically appropriate
way, but what are you really trying to accomplish? It seems that you are
using tables for layout - nested tables are _mostly_ an indication of that.
Then you might just as well use <table align="right"> for the inner table.
Alternatively, you could try and implement the layout in CSS instead of a
mixed approach.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #3

P: n/a
Jukka K. Korpela wrote:
"André Hänsel" <an***@webkr.de> wrote:
When I put a table into a table and try to align it right, it works
in IE but not in Firefox.
Usually when people describe a problem that way, it's in reality
Firefox that gets things right and IE wrong.


Yes, of course me and IE were wrong, that's why I asked how to do it right.
:)
The text-align property affects, by CSS specifications, the alignment
of text lines inside the element. The inner table is a block element,
so it is not affected. The text-align property is inherited into the
inner td so the line ultimately gets aligned to the right, but only
within its container, the cell, and the width of the container is
here just as much as needed for it. IE, as so often, gets this wrong.


By the way, so I got a nice description of my problem. ;)
How do I align it right "rightly". ;)


Using float: right as suggested by Els would be the technically
appropriate way, but what are you really trying to accomplish? It
seems that you are using tables for layout - nested tables are
_mostly_ an indication of that. Then you might just as well use
<table align="right"> for the inner table. Alternatively, you could
try and implement the layout in CSS instead of a mixed approach.


Yes, I'm using a table for layout... still an old vice. It's just one for
the overall layout of the page, but...

....probably I can also avoid even that.
I have one logo in the upper left corner, a box with a login form in the
upper right corner, the content in the middle and a footer line at the
bottom.
How does a correct CSS for that look like? Link?

Jul 21 '05 #4

P: n/a
Jukka K. Korpela wrote:
"André Hänsel" <an***@webkr.de> wrote:

When I put a table into a table and try to align it right, it works in IE
but not in Firefox.

[snip]
Using float: right as suggested by Els would be the technically appropriate
way, but what are you really trying to accomplish? It seems that you are
using tables for layout - nested tables are _mostly_ an indication of that.
As is using a table with one row and one column--that seems rather odd.
Then you might just as well use <table align="right"> for the inner table.
Alternatively, you could try and implement the layout in CSS instead of a
mixed approach.

Jul 21 '05 #5

P: n/a
Harlan Messinger wrote:
Jukka K. Korpela wrote:
"André Hänsel" <an***@webkr.de> wrote:
When I put a table into a table and try to align it right, it works
in IE but not in Firefox.


[snip]
Using float: right as suggested by Els would be the technically
appropriate way, but what are you really trying to accomplish? It
seems that you are using tables for layout - nested tables are
_mostly_ an indication of that.


As is using a table with one row and one column--that seems rather
odd.


What d'ya mean? ;)

Jul 21 '05 #6

P: n/a
André Hänsel wrote:
Harlan Messinger wrote:
Jukka K. Korpela wrote:
"André Hänsel" <an***@webkr.de> wrote:
When I put a table into a table and try to align it right, it works
in IE but not in Firefox.


[snip]

Using float: right as suggested by Els would be the technically
appropriate way, but what are you really trying to accomplish? It
seems that you are using tables for layout - nested tables are
_mostly_ an indication of that.


As is using a table with one row and one column--that seems rather
odd.

What d'ya mean? ;)


A table is a two-dimensional matrix of rows and columns (or even more
dimensions represented by a hierarchy of row and column headers and
subheaders). What do you think it means to have a table with one only
cell in it, as you do in your code?

<table>
<tr><td>test</td></tr>
</table>
Jul 21 '05 #7

P: n/a
Harlan Messinger wrote:
André Hänsel wrote:
Harlan Messinger wrote:
Jukka K. Korpela wrote:
"André Hänsel" <an***@webkr.de> wrote:
Using float: right as suggested by Els would be the technically
appropriate way, but what are you really trying to accomplish? It
seems that you are using tables for layout - nested tables are
_mostly_ an indication of that.

As is using a table with one row and one column--that seems rather
odd.


What d'ya mean? ;)


A table is a two-dimensional matrix of rows and columns (or even more
dimensions represented by a hierarchy of row and column headers and
subheaders). What do you think it means to have a table with one only
cell in it, as you do in your code?


Well, I could not imagine that it has any influence on the alignment of _the
table itself_, what is _in_ the table, so I used a table with only one cell.

Jul 21 '05 #8

P: 1
You can also just set style="display: inline;" on the table. This will make the table act like text instead of its own block. That way if you want to center it later you can.

JT

:cool:

Hi!

When I put a table into a table and try to align it right, it works in IE
but not in Firefox.

Simplest code to reproduce:
<html>
<body>
<table style="width: 100%">
<tr>
<td style="width: 50%">
blabla
</td>
<td style="width: 50%; text-align:right;">
<table>
<tr><td>test</td></tr>
</table>
</td>
</tr>
</table>
</body>
</html>

How do I align it right "rightly". ;)

Regards, André
Jul 1 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.