HTML - <center> Tag
Introduction to <center> Tag
The HTML <center> tag is used horizontally align the content to the center of its containing element. It is simple way to center text, images or other elements.
The HTML <center> tag is no longer recommended and deprecated in HTML5, because its functionality can be better achieved using CSS for separation of structure and style.
Despite of its deprecation, the <center> tag is still recognized by most of the browsers for backward compatibility. But the modern web encourages using CSS properties like text-align:center; for text or margin:auto; for block-level elements to achieve centering.
Syntax
Following is the syntax of HTML <center> tag −.
<center>...</center>
Attributes
HTML cenetr tag supports Global and Event attributes of HTML.
Example : Basic Usage
Let's look at the following example, where we are going to consider thr basci usage of the <center> tag.
<!DOCTYPE html>
<html>
<body>
<center>
<h1>Welcome to TutorialsPoint</h1>
</center>
</body>
</html>
Example : Alternative to Center Text
Considering the following example, where we are going to use the text-align:center; to center the text within the <div> element.
<!DOCTYPE html>
<html>
<style>
.a {
text-align: center;
color:#a569bd;
}
</style>
<body>
<div class="a">
<h1>TUTORIALSPOINT</h1>
</div>
</body>
</html>
Example : Alternative to Center Block Elements
In the following example, we are going to use the margin:auto; to center the block level element.
<!DOCTYPE html>
<html>
<style>
.a {
margin: auto;
width: 50%;
text-align: center;
font-family:verdana;
color:#145a32;
}
</style>
<body>
<div class="a">
<p>Welcome to the TutorialsPoint</p>
</div>
</body>
</html>
Supported Browsers
| Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| center | Yes | Yes | Yes | Yes | Yes |




