W3C home > Mailing lists > Public > www-style@w3.org > December 2002

Should centering a table center the caption?

From: Marc-Etienne Vargenau <vargenau@free.fr>
Date: Tue, 17 Dec 2002 14:39:54 +0100 (CET)
To: www-style@w3.org
Message-ID: <1040132394.3dff292af09d8@imp.free.fr>

Hello,

I need some expert advice on centering a table with CSS.

I know that I have to use
margin-left:auto; margin-right: auto;
to center the table with CSS.

With Opera, this centers the whole table, i.e. the cells and the caption.
With Mozilla, this centers only the cells, not the caption.

Who is right?

Expert advice with reference to CSS 2 document only please.

Test case below.

Regards,

Marc-Etienne Vargenau

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
 
<html>
  <head>
    <title>caption css center</title>
    <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
table {margin-left:auto; margin-right: auto; width:300px; border:solid green}
caption {width:300px; border:solid red}
</style>
  </head>

  <body>
    <table>
      <caption>
        caption
      </caption>

      <tr>
        <td>cell</td>

        <td>
        </td>
      </tr>
    </table>
  </body>
</html>


-- 
Marc-Etienne Vargenau http://vargenau.free.fr
Received on Tuesday, 17 December 2002 08:39:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:18 GMT