Closed Bug 151458 Opened 22 years ago Closed 22 years ago

stylesheet body {text-alignment: center} does not apply to tables

Categories

(Core :: Layout, defect)

x86
Windows 2000
defect
Not set
minor

Tracking

()

VERIFIED DUPLICATE of bug 49274

People

(Reporter: nickgsuperstar, Assigned: attinasi)

Details

From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
BuildID:    2002053012

Using a CSS style sheet to specify that the BODY tag has a TEXT-ALIGN of center 
should make every "block" be centered (i.e. equiv of the old <center>... 
</center>?).  text is aligned correctly, but tables are are always aligned with 
the left-side of the page. 

I'm very new to this, so excuse me if I'm misunderstanding something.  I've 
also tried to find dups, but with no luck.



Reproducible: Always
Steps to Reproduce:
See example html & css below.

Actual Results:  Table is left-justified (i.e. table starts at left edge of 
page).

Expected Results:  Table should be in middle of page. This is the behavior of 
IE 6.
 According to the CSS2 spec at
http://www.w3.org/TR/REC-CSS2/text.html#propdef-text-align
It appears that this is the correct behavior, but I'm no expert.

Here's style sheet:
body {
  text-align: center
}

Here's an HTML doc that uses a css and causes the problem:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>   <head><title>junk</title>                                             
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">link 
href="junk.css" rel="stylesheet" type="text/css"></head>
<body>
<h1>This is Centered</h1>                                                       
<table border="3"><tr>
<td>This is not</td>
</tr></table></body></html>
> I've also tried to find dups, but with no luck.

There are several. Bug 49274 appears to be the canonical one.
Quote from the CSS2 spec:

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

Note that only inline, and not block content should be centered.

(Agreement with the resolution of Bug 49274.
Hi,

thanks for the references.  It does appear that table {left|right-margin: auto}
does the job, and that "body {text-align: center}" is invalid according to spec,
in spite that NS4.7 and IE6 choose to do it anyways.

Reading the spec, while good, is not a quick read.  Given the number of times
this bug is reported, I suspect there are probably dozens of other similar
"bugs".  I would imagine you would get a lot of "it does this with this browser,
but not in Mozilla" bug report reguarding layout.   It's hard telling what's a
bug in mozilla, versus what's a bug in IE (or others), versus what's the spec
say.      The spec is good, but it's long and not a quick read.

Perhaps it's a good idea to make a "top layout bugs or anti-bugs" list or FAQ. 
 This would save your time (triage) , and mine (writing bug reports takes a lot
of time!).   This might fall somewhere between bugs and "developer relations". 
Maybe you have this already and I didn't see it?

I'm willing to volunteer some time on this.   Given the amount of time I spent
on this silly thing already, I might as well generalize it to other cases.

thanks

--nickg

*** This bug has been marked as a duplicate of 49274 ***
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
v.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.