<center>

The HTML <center> element, now deprecated, was utilized to center text or content within its container. CSS is now the preferred method for alignment and layout.

center Tag

The <center> HTML element is a block-level element that centers its content, whether block-level or inline, within its parent element.

Syntax

index.html
<center>Centered Text or Content</center>

center Demo

This text will be centered.

So will this paragraph.

index.html
<center>
  This text will be centered.
  <p>So will this paragraph.</p>
</center>

DOM Interface

This element implements the HTMLElement interface.

See Also

  • text-align
  • display

Conclusion

The <center> element was once commonly used to center content horizontally, but it is now deprecated. Modern web development practices recommend using CSS for centering, as it provides greater flexibility and control. Using CSS ensures better accessibility, compatibility, and maintainability. Instead of <center>, use text-align: center for inline elements or wrap content in a <div> and apply margin: 0 auto for centering block elements.