<center>
Published Mar 17, 2022Updated Aug 13, 2023
Contribute to Docs
The <center>
element was used historically to center content, usually text, within its containing elements.
Note: This element has since been deprecated and removed from the HTML specification. While some browsers might support it for backwards compatibility, it should no longer be used. The current practice in HTML is to use the CSS property
text-align
to center text and to use properties of the CSS box model to center other elements.
Syntax
<center><!-- text or other element to center goes here --></center>
<center>
was typically found as a child of the <body>
element to center elements on the page.
Example
Historical use:
<!-- Don't use this! --><center>This is centered text.<p>This is a centered paragraph</p></center>
The modern alternative is using a <div>
element, instead:
<!-- Use this, instead. :) --><div style="text-align:center;">This is centered text.<p>This is a centered paragraph</p></div>
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner Friendly7 hours