472,108 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,108 software developers and data experts.

text-align: right in Firefox

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
8 19821
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
"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
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
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
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
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
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
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.

Similar topics

2 posts views Thread by Macsicarr | last post: by
2 posts views Thread by Jiri Palecek | last post: by
4 posts views Thread by Arif Çimen | last post: by
3 posts views Thread by jweinberg1975 | last post: by
3 posts views Thread by bbepristis | last post: by
10 posts views Thread by bluemountain | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.