Description

The <center> element aligns contents in the center of the enclosing block.

Usually, centers are rendered visually by indentation. A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> element.

The following table summarizes the usages context and the version history of this tag.

Placement:Block
Content:Block, inline and text
Start/ End Tag:Start tag: required, End tag: required
Version:HTML 3.2, 4, 4.01 (transitional)

Warning: Don't use this tag since it is a non-standard tag and has been deprecated in HTML 4.01 and obsolete since HTML5. Use CSS instead, to center content.

Syntax

The basic syntax of the <center> tag is given with:

HTML/XHTML: <center> ... </center>

The example below shows the <center> tag in action.

<!--Example of bad usage. Don't use this tag-->
<center>This paragraph will be centered.</center>
<!--Alternative-->
<p style="text-align: center;">This paragraph will be centered using CSS.</p>

Tip: To give a similar effect to the center tag, use the CSS text-align property, which can be applied to the <div> element or to an individual <p>.

Tag-Specific Attributes

The <center> tag doesn't have any specific attribute.

Global Attributes

Like all other HTML tags, the <center> tag supports the glocenteral Attributes in HTML5.

Event Attributes

The <center> tag also supports the event Attributes in HTML5.

Browser Compatibility

Element
<center>YesYesYesYesYes