center (HTML element)

Spec
Depr. Empty Version
Yes No HTML 3.2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

<center>
</center>

Description

The center element almost needs no description—the clue to its purpose is right there in its name! It centers content. This is a block-level element, so each new center element you create will produce a new block of content:

<center>This is centered</center>
<center>So is this</center>
<center>And this is centered too</center>

The above markup would render as shown in Figure 1.

Figure 1. Three lines of centered text Three lines of text centered

Note that, unlike paragraphs that are set using the p element, margins don’t appear above or below the three lines in this case.

This element was originally created by Netscape, but it was integrated into HTML 3.2 (the update to HTML 3, which hadn’t included this element) because it was so widely used online. It has since been deprecated in favor of using CSS for centering content.

Example

The center element is typically used in a menu:

<center>
<h1>Lunch Menu</h1>
<p>All food cooked fresh to order.</p>
<h2>Starters</h2>
⋮
</center>

Use This For …

The center element could be wrapped around all the content on a page—an approach that would affect not just the text, but the images and tables that are on the page as well. There are not that many instances in which this kind of effect is desirable or aesthetically pleasing, aside from the alignment of items in a menu, as shown above. The best advice is to not use this element, because it’s not present in the current HTML/XHTML (Strict) standards, and thus it will cause the document in which it’s used to be invalid. Instead, use CSS to center content: a div element may be used as a wrapper for the content to which the CSS text-align:center; is applied to take care of text alignment.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Every browser listed supports this element type.

User-contributed notes

Related Products