"http://www.w3.org/TR/REC-html40/strict.dtd"> CENTER - Centered Block

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:

<CENTER>
  <TABLE>
    <TR ALIGN=center>
      <TH SCOPE=col>Name</TH>
      <TH SCOPE=col>Age</TH>
      <TH SCOPE=col>Country</TH>
    </TR>
    <TR ALIGN=center>
      <TD>Liam Quinn</TD>
      <TD>20</TD>
      <TD>Canada</TD>
    </TR>
  </TABLE>
</CENTER>

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