Bug 49274 (cssCenterTable)

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

VERIFIED INVALID

Status

()

Core
Layout: Tables
P3
normal
VERIFIED INVALID
18 years ago
9 years ago

People

(Reporter: Koike Kazuhiko, Assigned: karnaze (gone))

Tracking

({compat, testcase})

Trunk
x86
Windows 98
compat, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

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

Win98 2000081508
(Reporter)

Comment 1

18 years ago
Created attachment 13026 [details]
testcase

Comment 2

18 years ago
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

Comment 3

18 years ago
Created attachment 13039 [details]
another testcase

Comment 4

18 years ago
Created attachment 13040 [details]
testcase with strict mode

Comment 5

18 years ago
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

Comment 6

17 years ago
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
Last Resolved: 17 years ago
Keywords: 4xp → compat, verifyme
Resolution: --- → INVALID
(Reporter)

Comment 8

17 years ago
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.

Comment 10

17 years ago
Verified invalid. text-align aligns text, not blocks
Status: RESOLVED → VERIFIED
*** Bug 63489 has been marked as a duplicate of this bug. ***

Comment 12

17 years ago
*** 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. ***

Updated

17 years ago
Keywords: verifyme
*** Bug 87562 has been marked as a duplicate of this bug. ***
*** Bug 79932 has been marked as a duplicate of this bug. ***

Comment 21

17 years ago
*** Bug 94928 has been marked as a duplicate of this bug. ***
*** Bug 94928 has been marked as a duplicate of this bug. ***

Comment 23

16 years ago
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. ***

Comment 25

16 years ago
*** Bug 111325 has been marked as a duplicate of this bug. ***
*** Bug 111961 has been marked as a duplicate of this bug. ***

Comment 27

16 years ago
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.

Comment 28

16 years ago
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. ***

Comment 34

15 years ago
*** Bug 186265 has been marked as a duplicate of this bug. ***

Updated

15 years ago
Alias: cssCenterTable

Comment 35

15 years ago
*** 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. ***

Comment 38

12 years ago
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)

Comment 39

12 years ago
Just've raised new bug #343862

Comment 40

12 years ago
*** 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. ***

Comment 43

11 years ago
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.

Comment 44

11 years ago
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.

Updated

11 years ago
Duplicate of this bug: 384020

Updated

9 years ago
Duplicate of this bug: 476416
You need to log in before you can comment on or make changes to this bug.