HTML <center> tag
The <center> tag is used to define center-align text. It is no longer supported in HTML5.
Type: Inline Element
Syntax of <center> tag
<center> Center-align text </center>
Supported Browsers
| Tag | Chrome | Internet Explorer | Firefox | Safari | Opera Mini |
|---|---|---|---|---|---|
| <center> | Yes | Yes | Yes | Yes | Yes |
Full code example
Since the <center> element is not supported in HTML5, the document needs to write in HTML 4.01 Transitional standard..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <p> <center> Center-align text. </center> </p> </body> </html>
Output on the browser
Center-align text.
More reference
The function of <center> tag is replaced by the CSS text-align property. Example:
text-align: left|right|center|justify|initial|inherit;
text-align value
| Value | Note |
|---|---|
| left | It makes the text left alignment. |
| right | It makes the text right alignment. |
| right | It makes the text center alignment. |
| right | It preserves text both right and left alignment by stretching all the lines at the max distance equally. |
| right | It sets the text-alignment to default value (for <caption> element, texts are center-align.) |
| inherit | It inherits from the parent value. |
