table-layout-property-002

Centering a table in its containing block by setting its left and right margins to 'auto'

WeasyPrint

This browser

Assertion
A table can be centered in its containing block by setting its left and right margins to 'auto'.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3     <head>
 4         <title>CSS Test: Centering a table in its containing block by setting its left and right margins to 'auto'</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/tables.html#width-layout">
 7         <meta name="flags" content="">
 8         <meta name="assert" content="A table can be centered in its containing block by setting its left and right margins to 'auto'.">
 9         <style type="text/css">
10             div
11             {
12                 border: solid black;
13                 width: 300px;
14             }
15             table
16             {
17                 background: blue;
18                 color: blue;
19                 margin-left: auto;
20                 margin-right: auto;
21                 width: auto;
22             }
23         </style>
24     </head>
25     <body>
26         <p>Test passes if the blue box below is centered within the black box.</p>
27         <div>
28             <table>
29                 <tr>
30                     <td>Filler Text Filler Text</td>
31                 </tr>
32                  <tr>
33                     <td>Filler Text Filler Text</td>
34                 </tr>
35                  <tr>
36                     <td>Filler Text Filler Text</td>
37                 </tr>
38              </table>
39           </div>
40     </body>
41  </html>