text-align:center does nothing on text inside tables

VERIFIED DUPLICATE of bug 49274

Status

()

Core
Layout
VERIFIED DUPLICATE of bug 49274
18 years ago
18 years ago

People

(Reporter: Fulvio Malfatto, Assigned: karnaze (gone))

Tracking

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

468 bytes, text/html
Details
343 bytes, text/html
Details
(Reporter)

Description

18 years ago
I have this html sample working on IE and Netscape and not
respecting the align-center clause under Mozilla ... it seems correct
to me ... what have I to change ?

<HTML><HEAD><TITLE></TITLE>
<STYLE type=text/css>
.centered {TEXT-ALIGN: center }
</STYLE>
</HEAD>
<BODY>
<DIV class="centered">
<TABLE border=1>
 <tr>
 <td>This text should be centered
 </td>
 </tr>
</TABLE>
</DIV>
</BODY></HTML>

Comment 1

18 years ago
->layout. Hixie, could you please say whether this is valid? I'm not sure but
there's no reason that text-align should affect the way the table is aligned,
and if you want the text in the cell to be centered, you have to put the class
on the <td>. That's only how I see it, I may be totally wrong
updating summary
Assignee: asa → karnaze
Component: Browser-General → Layout
QA Contact: doronr → petersen
Summary: align-center not respected → text-align:center does nothing on text inside tables

Comment 2

18 years ago
Text align is used to align text, a table isn't text. If you want to align both
the table and text, with CSS, then you should use two different styles. One for
the <table> and one for <td> See attachment

Comment 3

18 years ago
Created attachment 24877 [details]
Example
(Reporter)

Comment 4

18 years ago
The problem is not the text inside the table, but that the whole table is left 
aligned in the page whit mozilla, and centered in other browsers :
all object inside the <div> are not centered on the 
document ... as they appear normally.

Comment 5

18 years ago
Aha, then the summary is incorrect, right? And I just run the inline testcase on
MSIE 5 and there it didn't align centered, nor did it in Opera version 4 and
version 5. Attachment 24877 [details] will run in Mozilla, Opera 4 and 5 correct, but not
in MSIE 5.

Mozilla is doing the right thing here! See next clear testcase for text align!

Comment 6

18 years ago
Created attachment 24883 [details]
Example

Comment 7

18 years ago
Correction, the inline testcase does align centered in MSIE 5.

note: inline testcase is your source

Comment 8

18 years ago
Ok, it seems you want to align the table with text-alignm that will make this a
dup of bug 49274 i guess.

Comment 9

18 years ago
HJ, you rock, thanks for finding this!!

*** This bug has been marked as a duplicate of 49274 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → DUPLICATE

Comment 10

18 years ago
verf.

The "real" way to get tables centered is to set the l/r margins to auto. :-)
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.