text-align: center does not replace align="center" for tables in div

VERIFIED INVALID

Status

()

VERIFIED INVALID
16 years ago
14 years ago

People

(Reporter: fred, Assigned: dbaron)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
If I want to center a TABLE within a DIV I must use align="center".

You can play with the example :

If text-align:center and 'align' is not set, only the text is centered in the DIV.

If text-align is not set and align="center", text and table is centered in the DIV.

If text-align:center and align="center", only the text is centered in the DIV.

Regards,
Fred.

Comment 1

16 years ago
You're not doing the CSS correctly.

If you want your table to be centered in a div, you add:

margin-left:            auto;
margin-right:           auto;

to the table element in your CSS. 

Marking as invalid. 
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID
Agreed.  We implement 'text-align: center' to have the meaning described in the
CSS specs, while we implement align="center" to have the strange
backwards-compatible behavior.  MSIE's implementation of the CSS property is
buggy since it made the CSS property compatible with the HTML align="center",
which it need not be.
Status: RESOLVED → VERIFIED

Comment 3

14 years ago
*** Bug 260328 has been marked as a duplicate of this bug. ***

Comment 4

14 years ago
*** Bug 272173 has been marked as a duplicate of this bug. ***

Comment 5

14 years ago
Hate to say this, but IE uses a common sense behavior, that's backward
compatible. See this test case:
http://www.hyperpublish.com/firedivbug/
( http://www.hyperpublish.com/firedivbug/firebug_style.css )

The table is within:
<DIV align=center class=s2>
See it with all the other browsers.

The class s2 has text-align=center; the align=center within the DIV was actually
there (hystorically) mostly in order to make the code backward compatible (from
NS 3.0). FYI the code in that page is automatically generated. 

All the other browsers when you use a text-align:center do render the table
centererd (IE, Opera, Netscape since 3.0). As a table is actually a group of
text, I don't think you are so correct - your interpretation of CSS2
specifications is opinionable. To say one, I do not second it. I think you are
wrong. I second the interpretation followed by the other browsers.

Apart from this formal dispute that could be neverending, let's face the facts,
in any case you end to create an incompatibility. You say "MSIE's (and Netscape
and Opera) implementation of the CSS property is buggy since it made the CSS
property compatible with the HTML align=center, which it need not be". 

It needs to be. Mainly because any intelligent automatic editor (such as
EasyWebEditor) needs to create code that's backward compatible (as we do; our
pages are good also with old browsers) so it must create a code that's both
similar to the old HTML align AND contains CSS for the new browsers.
Your refuse to do what the other browser do, and by the way what it was for sure
certainly OK in all CSS1 implementations (so maybe not correct but unfortunately
already "out there"), makes it extremely complicated to create a good automatic
editor. 
As you may know, a decent web editor should attempt to be backward compatible
with all the standards, formal or "de facto". I hate to say this, but this time
Microsoft (and the others) seems to have more common sense than you. Nowadays a
small percent of people do actually edit the HTML code. Or maybe you desire that
all people do use Front Page (that's not so strong for compatibility)?

With your approach, the only automatic workaround I see for the code cited (that
would be needed ONLY for Firefox) should be: if a DIV contains a table that is
not left-aligned, then create a class (e.g. s2-bis) with the weird "auto"
margins. This is not simple, it makes the code prolix and I am not really sure
that margin-left: auto (etc.) is rendered same way for all the other browsers,
specially old ones, I think it does not work with IE 4 and 5 to say one, this
actually trashes the "compatible with any browser" phylosophy. And what happens
with right alignment? If your approach "de facto" gives problems with the other
browsers, I think you should consider to implement the "normal" behavior as for
compatibility, specially in this case where what you consider formally correct
is near to a nonsense (the code tells you 2 times to center and you do not!). 

For your information, we tested dozens of browsers for our web software products
(EasyWebEditor, 1SITE, HyperPublish, 100000+ users) and our philosophy is
"compatible with any browser" rather than "W3C compatible" as real people needs
tools for the real world.

I think Firefox is really great and we've found only this issue.
I think you should follow the "normal" interpretation of the text-align:center
If you are concerned, you can let the user disable this behavior by un-checking
a "backward alignment compatible" checkbox. 

Comment 6

14 years ago
I just had a simplest workaround idea, and I just tried the margin: auto as you
suggested, overriding the class within the DIV tag by using the "style" keyword.

Doesn't work.

http://www.hyperpublish.com/firedivbug2/

I think you have actually some code that when text-align is center and a table
is within the par then it forces to LEFT align the table. My suggestion is now
stronger.
You need to log in before you can comment on or make changes to this bug.