Closed Bug 123419 Opened 23 years ago Closed 23 years ago

CSS text-align not working for Tables

Categories

(Core :: Layout, defect)

x86
Windows NT
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 49274

People

(Reporter: ray.au, Assigned: attinasi)

Details

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.7+)
Gecko/20020115
BuildID:    2002011503

If I specify a <DIV> with the CSS property "text-align:center" tables within the
<DIV> will not center, but text works just fine. Take this code for example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
    <div style="text-align:center">
        some text
        <table border="1" width="500" cellpadding="0" cellspacing="0">
            <tr>
                <td>hello</td>
            </tr>
        </table>
        more text
    </div>
</body>
</html>

Notice "some text" and "more text" is properly centered within the page, but the
table is not. "text-align" is supposed to apply to block-level elements.
Shouldn't this then apply to <TABLE>'s too?

Reproducible: Always
Steps to Reproduce:
1. load page with the html


Actual Results:  <TABLE>'s seem to be using the default alignment as if the
text-align from the stylesheet was ignored.

Expected Results:  <TABLE> should be center aligned as per stylesheet rules.
Attached file sample html file
Adding a sample html file to show "problem." Notice text and images (a dead
image) align properly.
Well this is because of the simple fact that a table is not text.  Which is why
the text is aligned, but not the table.

If you want to center the table you need 

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

The same holds true for any other block level element you wish to "center"
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
Actually this is a dupe of bug 49274
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
...But my original comments still stand.

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

Attachment

General

Creator:
Created:
Updated:
Size: