Closed Bug 49274 (cssCenterTable) Opened 24 years ago Closed 24 years ago

"text-align:center;" doesn't center table

Categories

(Core :: Layout: Tables, defect, P3)

x86
Windows 98
defect

Tracking

()

VERIFIED INVALID

People

(Reporter: kazhik, Assigned: karnaze)

References

Details

(Keywords: compat, testcase)

Attachments

(3 files)

<div style="text-align:center"> doesn't center table.

Win98 2000081508
Attached file testcase
This differs from IE5 and Nav4.6. As the document  has a  transitional dtd this
should trigger quirks mode and give the same result as Nav4.6. Adding some
keywords. But I am not sure what the standard is, how this should behave.
Keywords: 4xp, testcase
Attached file another testcase
My understanding is that the table as part of the textblock should aligned. 
http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-align
Please see also the difference between strict and transitional testcases.
Confirming the bug
Status: UNCONFIRMED → NEW
Ever confirmed: true
You should use:

table { margin-left: auto; margin-right: auto; }

This works in Mozilla and Opera 4; 'text-align: center' should *not* work. 
Should be marked 'invalid'.
text-align affects the *text*, hence the name *text*-align. 

A table is not text.
Status: NEW → RESOLVED
Closed: 24 years ago
Keywords: 4xpcompat, verifyme
Resolution: --- → INVALID
I can't agree with marking this bug as invalid.

(1) <div style="text-align:center"> can center table with IE 5.x and NC 4.x.

(2) "text-align" should apply to block elements. table is also a block element.

http://www.w3.org/TR/REC-CSS1#text-align
Yes, text-align *applies* to block elements, in CSS terms. But that does not 
mean that it *affects* block elements. It *affects* the text content of blocks.
The specification is *VERY* clear about this. Read the chapters on the 
formatting model for details.
Verified invalid. text-align aligns text, not blocks
Status: RESOLVED → VERIFIED
*** Bug 63489 has been marked as a duplicate of this bug. ***
*** Bug 68278 has been marked as a duplicate of this bug. ***
*** Bug 68954 has been marked as a duplicate of this bug. ***
*** Bug 73696 has been marked as a duplicate of this bug. ***
*** Bug 74462 has been marked as a duplicate of this bug. ***
*** Bug 77501 has been marked as a duplicate of this bug. ***
*** Bug 78872 has been marked as a duplicate of this bug. ***
*** Bug 85667 has been marked as a duplicate of this bug. ***
Keywords: verifyme
*** Bug 87562 has been marked as a duplicate of this bug. ***
*** Bug 79932 has been marked as a duplicate of this bug. ***
*** Bug 94928 has been marked as a duplicate of this bug. ***
*** Bug 94928 has been marked as a duplicate of this bug. ***
Here is an interesting quote for you:

| The table itself is centered, by setting its left and right margins
| to 'auto',
| [...]
| TABLE {
|     margin-left: auto;
|     margin-right: auto
| }
| [...]
       - CSS2 Specification

Visit http://www.w3.org/TR/REC-CSS2/tables.html#q5 to see the original
text. So in case someone doubts, it was correct to mark this bug as invalid.
*** Bug 111325 has been marked as a duplicate of this bug. ***
*** Bug 111325 has been marked as a duplicate of this bug. ***
*** Bug 111961 has been marked as a duplicate of this bug. ***
Is it just me, or does it seem like CSS *should* have a non-text align: table { 
align: center; }

It seems logical to not deprecate a feature unless it is being replace, margin: 
auto; seems like nothing more then a *hack*, ahh well.
Well, actually this 'hack' IS what's the official recommendation of the W3C. So
mozilla does hanlde this right and should definitly NOT change this behavior
because of compatibility issues!

If this is 'userfriendly' =) is just another question. I had to take a deep look
into the specs myself before realizing this (and after filing a bug for this
issue =) - nevertheless it's not mozilla's turn to innovate here. As the W3C
recommendations are RFCs (Request for Comment), you just could do so and suggest
such a feature. (that's why the RFCs are called so). You could go to
http://www.w3.org/Style/CSS/current-work and find out about the plans for CSS3
and actually drop a comment, as they do request so. See? Go there and nag them.
And IF this makes it into CSS3, mozilla will certainly render this correctly once.
*** Bug 119411 has been marked as a duplicate of this bug. ***
*** Bug 123419 has been marked as a duplicate of this bug. ***
*** Bug 151458 has been marked as a duplicate of this bug. ***
*** Bug 160049 has been marked as a duplicate of this bug. ***
*** Bug 184356 has been marked as a duplicate of this bug. ***
*** Bug 186265 has been marked as a duplicate of this bug. ***
Alias: cssCenterTable
*** Bug 200423 has been marked as a duplicate of this bug. ***
*** Bug 245214 has been marked as a duplicate of this bug. ***
*** Bug 290680 has been marked as a duplicate of this bug. ***
Reading thoroughly the specs...
1* http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-align
"This property describes how inline content of a block is aligned"

2* http://www.w3.org/TR/REC-CSS2/tables.html#column-alignment
cell is block-level element, as div is.
"The horizontal alignment of a cell's content within a cell box is specified with the 'text-align' property"

both quotes refer just to content(1st quote has nothing about block-level or inline-level elements if to be overparticular)

3* http://www.w3.org/TR/REC-CSS2/visuren.html#block-level
4* http://www.w3.org/TR/REC-CSS2/visuren.html#inline-level

From the other side let's look at HTML specs
5* http://www.w3.org/TR/html401/present/graphics.html#h-15.1.2
There are examples with <p> which is block-level element (3* example with <div><p>)
Also there is interesting comment about <center> an the end of 5*

<center><table/></center> = <div aligh="center"><table/></div>
^^^^^^^^^^^^^^^^^^^^^^^^^
= <div style="text-align: center"><table/></div>
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
considering both <table> and <p> are box-level elements(examples in 5* & 3*)

IT'S THE BUG.

Please, prove the opposite, don't guess - PROVE(with references)
Just've raised new bug #343862
*** Bug 343862 has been marked as a duplicate of this bug. ***
*** Bug 343862 has been marked as a duplicate of this bug. ***
*** Bug 349391 has been marked as a duplicate of this bug. ***
Andrew, it's not a bug.
I've come here thinking it was a bug, but did a little search about text-align 
(which is the important thing here) and found this:

 - This property describes how "inline content of a block" is aligned.

 - In this example, note that since 'text-align' is inherited, all "block-level elements" inside DIV elements with a class name of 'important' will have "their inline content" centered: div.important { text-align: center }

Source: http://www.w3.org/TR/CSS21/text.html#propdef-text-align

Note that I've marked with "" the significant parts.

Tables are block-level elements, so, in this case all the table's inline content will be centered (style inherited from the div to the table), but not the table itself, since it's not an inline-level element of the div.

Daniel is right when he points that the ceneting of block-level elements its something missing in CSS2.

I hope, this clear your doubt.
http://www.w3.org/TR/CSS21/tables.html#column-alignment

Interesting, how thas should be interpreted in current context?
No "inline", "inline-level", etc. mentioned there.
I am a newbie can I work on this bug?
Is the bug fixed??
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: