1. Home
  2. Computing & Technology
  3. Web Design / HTML

Simple Way to Center a Table Using CSS

By Jennifer Kyrnin, About.com

Now that the <center> tag is deprecated as is the align="center" attribute on table tags, how are you supposed to center your tables within your Web page? Luckily, there is a relatively easy way to do this using CSS.

Center a Table with CSS

table { margin: auto; }

When you have a table set in a Web page, or even within another block element (such as a div), you can center that table within the element by using the margin: auto; property in CSS. This property tells the browser to make the margins on all sides of the table equal. Which will, in turn, push the table into the center of the browser window.

Unfortunately, IE 6 Doesn't Support This

This is one of those standards based options that IE doesn't support. If you must design for IE, then you'll need to add in other styles for IE to center your tables.

More Web Design / HTML Quick Tips

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. Tables
  7. Simple Way to Center a Table Using CSS

©2008 About.com, a part of The New York Times Company.

All rights reserved.