HTML <center> Tag

The content of the <center> tag (text, graphic elements, tables and so on) is aligned to the center.

The <center> tag isn’t supported in HTML5. Instead, use CSS text-align property (see an example below).

Syntax

The content of the <center> tag is being written between the opening (<center>) and closing (</center>) tags.

The <center> tag is a block-level element, which means it can contain other block-level and inline elements.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p>This text is aligned to the left.</p>
    <center>And this one is placed in the center.</center>
  </body>
</html>

Result

Using CSS styles

As we’ve already mentioned, the <center> tag isn’t supported in HTML5․ Instead, we use CSS styles.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p>This text is aligned to the left.</p>
    <p style="text-align:center">And this one is placed in the center.</p>
  </body>
</html>

Result

Browser support