HTML Reference ยท Obsolete Elements
The <center> element (obsolete)
The HTML <center> element centered content and is obsolete. Learn why, how browsers still render it, and how to center text and boxes with CSS instead.
The <center> element displayed its content as a block with everything centered horizontally: text, images, and even nested tables and boxes.
Why it's obsolete
Centering is a visual decision, and HTML describes meaning. <center> was deprecated in HTML 4 and made obsolete in HTML5, once CSS could do the job more flexibly, for one page or a whole site at once.
Browsers still render it as a block that centers its contents, so old pages don't break.
Modern replacement
CSS separates two cases. Use text-align: center to center inline content (text, images, buttons) inside a box. Use margin-inline: auto with a width to center a box itself. Flexbox or grid handle anything more complex.
Note that text-align: center alone does not center the .card box; without margin-inline: auto it would still sit at the left edge.
Technical summary
| Status | Obsolete (non-conforming) |
| Replacement | CSS text-align: center, margin-inline: auto, flexbox or grid |
| Still rendered by browsers | Yes, as a centered block |
Related
<div>โ a generic container to style<font>โ another obsolete presentational element- Lesson: Deprecated and Obsolete Features
- Lesson: Page Layout