Easy Tutorial
❮ Tag Legend Tag Body ❯

HTML <center> Tag

Example

Center align text in an HTML page:

<center>This text is center-aligned.</center>

Browser Support

All major browsers support the <center> tag.


Tag Definition and Usage

In HTML 4.01, the <center> element is deprecated.

The <center> tag centers the text it contains.


Tips and Notes

Tip: Use CSS to center text! You can learn more about centering text in our CSS tutorial.


Differences Between HTML 4.01 and HTML5

HTML5 does not support the <center> tag, which was deprecated in HTML 4.01.


Standard Attributes

In HTML 4.01, the <center> tag supports the following standard attributes:

Attribute Value Description
class classname Specifies the class name for an element
dir rtl <br>ltr Specifies the text direction of the element's content
id id Specifies a unique id for an element
lang language_code Specifies the language of the element's content
style style_definition Specifies an inline style for an element
title text Specifies extra information about an element

For a full description, visit Standard Attributes.


Event Attributes

In HTML 4.01, the <center> tag supports the following event attributes:

Attribute Value Description
onclick script Script to be run on a mouse click
ondblclick script Script to be run on a double-click
onmousedown script Script to be run when a mouse button is pressed
onmousemove script Script to be run when the mouse pointer moves
onmouseout script Script to be run when the mouse pointer moves out of an element
onmouseover script Script to be run when the mouse pointer hovers over an element
onmouseup script Script to be run when a mouse button is released
onkeydown script Script to be run when a key is pressed
onkeypress script Script to be run when a key is pressed and then released
onkeyup script Script to be run when a key is released

For a full description, visit Event Attributes.

❮ Tag Legend Tag Body ❯