Skip to content

<center> - Centered Text (Deprecated)

Deprecated HTML 3.2

The <center> element was a block-level element that horizontally centered all of its inline and block-level content. It was introduced in HTML 3.2 (1997) and deprecated in HTML 4.01 (1999), then completely obsoleted in HTML5 (2014).

This is how the <center> element was used in older websites:

Result

While this still works in modern browsers, it mixes presentation with structure, which violates modern web development principles.

The <center> element was deprecated for several important reasons:

Separation of Concerns: HTML should describe the structure and meaning of content, while CSS handles presentation and styling. The <center> element violates this principle by embedding visual presentation directly into the markup.

Maintainability: With CSS, you can change the alignment of multiple elements across your entire site by modifying a single stylesheet. With <center>, you must edit each HTML file individually.

Flexibility: CSS provides far more centering options than <center> ever did, including vertical centering, responsive centering, and centering within flex or grid containers.

Semantics: The <center> element conveys no semantic meaning about the content. Modern HTML emphasizes semantic elements that describe what content is, not how it looks.

Accessibility: CSS-based centering works better with assistive technologies and responsive designs, adapting to different screen sizes and user preferences.

For centering inline content (text, images, inline elements) within a block container:

Result

The text-align: center property centers inline content within its container. This is the direct replacement for most <center> use cases.

For centering block-level elements horizontally:

Result

The margin: 0 auto technique centers block elements by setting left and right margins to auto. The element must have a defined width or max-width.

For centering content both horizontally and vertically:

Result

Flexbox provides powerful centering capabilities. justify-content: center centers horizontally, while align-items: center centers vertically.

For centering with CSS Grid:

Result

The place-items: center property is shorthand for centering both horizontally and vertically in a grid container. It’s the most concise centering method available.

Here’s how to convert old <center> markup to modern CSS:

<!-- Don't use this -->
<center>
<h1>Page Title</h1>
<p>Some centered text.</p>
<img src="logo.png" alt="Logo">
</center>
<center>
<div style="width: 600px;">
Centered content block
</div>
</center>

Simple text and inline elements: Replace <center> with a <div> and text-align: center.

Block elements with width: Replace <center> with margin: 0 auto on the block element itself.

Complex layouts: Consider using flexbox or grid for more sophisticated centering that also handles vertical alignment and responsive behavior.

Multiple centered sections: Create a reusable CSS class rather than repeating inline styles or multiple <center> tags.

The <center> element was widely supported during its active lifetime:

BrowserSupport PeriodCurrent Status
Netscape2.0 - 9.0Legacy support only
Internet Explorer3.0 - 11.0Legacy support only
ChromeAll versionsLegacy support only
FirefoxAll versionsLegacy support only
SafariAll versionsLegacy support only
EdgeAll versionsLegacy support only

Modern browsers maintain backward compatibility with <center> but mark it as obsolete. It does not validate in HTML5 documents and should not be used in any new development.

Generic block container. Use with CSS text-align or flexbox/grid for centering. Learn more →

Paragraph element. Apply text-align: center via CSS class for centered paragraphs. Learn more →

The <center> element appeared in the following specifications:

HTML 3.2 (1997): First standardized appearance. The element was created to match existing browser implementations.

HTML 4.01 (1999): Deprecated in favor of CSS text-align property. W3C recommended avoiding it in new documents.

XHTML 1.0 (2000): Marked as deprecated. Strict XHTML prohibited its use entirely.

HTML5 (2014): Completely obsoleted and removed from the specification. Listed in the “obsolete features” section for reference only.

Current Standard: WHATWG HTML Living Standard lists <center> as a non-conforming feature. The specification states it must be treated as a <div> element with text-align: center in the user agent stylesheet.

Further Reading: MDN Web Docs: Deprecated and Obsolete Features