The Web Design Group

center - Centered Block

Syntax <center>...</center>
Attribute Specifications
Contents Inline elements, block-level elements
Contained in applet, blockquote, body, button, center, dd, del, div, fieldset, form, iframe, ins, li, map, noframes, noscript, object, td, th

The center element defines a block whose contents are centered horizontally on visual browsers. <center> is a shorthand for <div align="center">, though center is slightly better supported among browsers. Both methods of centering are deprecated in favor of style sheets.

center is still useful for centering tables since many browsers lack support for <table align="center"> as well as the method of centering tables with Cascading Style Sheets (setting margin-left and margin-right to auto). An example follows:

    <tr align="center">
      <th scope="col">name</th>
      <th scope="col">age</th>
      <th scope="col">country</th>
    <tr align="center">
      <td>liam quinn</td>

Note that center only centers the table as a whole, not the contents of each table cell. The preceding example uses the align attribute of tr to center the contents of each cell. The text-align property of Cascading Style Sheets provides greater flexibility in suggesting horizontal alignment.

More Information