Search w3schools.com:

SHARE THIS PAGE

HTML <center> Tag. Not Supported in HTML5.


Example

Center-align text in an HTML page:

<center>This text will be center-aligned.</center>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The <center> tag is supported in all major browsers.


Definition and Usage

The <center> tag is not supported in HTML5. Use CSS instead.

The <center> element is deprecated in HTML 4.01.

The <center> tag is used to center-align text.


Tips and Notes

Tip: Use CSS to center text! In our CSS tutorial you can find more details about centering text.


Differences Between HTML 4.01 and HTML5

The <center> tag is not supported in HTML5, and is deprecated in HTML 4.01.


Standard Attributes

The <center> tag supports the following standard attributes in HTML 4.01:

Attribute Value Description
class classname Specifies a classname for an element
dir rtl
ltr
Specifies the text direction for the content in an element
id id Specifies a unique id for an element
lang language_code Specifies a language code for the content in an element
style style_definition Specifies an inline style for an element
title text Specifies extra information about an element

More information about Standard Attributes.


Event Attributes

The <center> tag supports the following event attributes in HTML 4.01:

Attribute Value Description
onclick script Script to be run on a mouse click
ondblclick script Script to be run on a mouse double-click
onmousedown script Script to be run when mouse button is pressed
onmousemove script Script to be run when mouse pointer moves
onmouseout script Script to be run when mouse pointer moves out of an element
onmouseover script Script to be run when mouse pointer moves over an element
onmouseup script Script to be run when 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 released
onkeyup script Script to be run when a key is released

More information about Event Attributes.




Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]