HTML <center>Tag -Not supported in HTML5
Examples
Center text horizontally in an HTML page:
<center>This text is center-aligned.</center>
Try it Yourself »
Browser Support
![]()
All major browsers support the <center> tag.
Definition and Usage
HTML5 does not support the <center> tag. Use CSS instead.
In HTML 4.01, the <center> elementis deprecated。
The <center> tag horizontally centers the text it contains.
Tips and Notes
Tip:Use CSS styles to center text! In the CSS tutorial you can learn more aboutcentering textthe details.
Differences between HTML 4.01 and HTML5
HTML5 does not support the <center> tag, and HTML 4.01 has deprecated the <center> tag.
Standard Attributes
In HTML 4.01, the <center> tag supports the following standard attributes:
| Attribute | Value | Description |
|---|---|---|
| class | classname | Specifies the class name of an element |
| dir | rtl ltr |
Specifies the text direction of the content in an element |
| id | id | Specifies the unique id of an element |
| lang | language_code | Specifies the language code of the content in an element |
| style | style_definition | Specifies the inline style of an element |
| title | text | Specifies additional information about an element |
For a complete description, please visitStandard Attributes。
Event Attributes
In HTML 4.01, the <center> tag supports the following event attributes:
| Attribute | Value | Description |
|---|---|---|
| onclick | script | Script to be run when the mouse is clicked |
| ondblclick | script | Script to be run when the mouse is double-clicked |
| onmousedown | script | Script to be run when a mouse button is pressed down |
| 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 complete description, please visitEvent Attributes。
Other extensions