table-layout-property-002.xht (1452B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 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="assert" content="A table can be centered in its containing block by setting its left and right margins to 'auto'." /> 8 <style type="text/css"> 9 div 10 { 11 border: solid black; 12 width: 300px; 13 } 14 table 15 { 16 background: blue; 17 color: blue; 18 margin-left: auto; 19 margin-right: auto; 20 width: auto; 21 } 22 </style> 23 </head> 24 <body> 25 <p>Test passes if the blue box below is centered within the black box.</p> 26 <div> 27 <table> 28 <tr> 29 <td>Filler Text Filler Text</td> 30 </tr> 31 <tr> 32 <td>Filler Text Filler Text</td> 33 </tr> 34 <tr> 35 <td>Filler Text Filler Text</td> 36 </tr> 37 </table> 38 </div> 39 </body> 40 </html>