HTML <center>
tag
The <center>
tag is a deprecated tag in HTML that was used to center-align content on a webpage. It is no longer supported in HTML5, and it is recommended to use CSS for styling instead.
Usage of the <center>
tag:
Previously, the <center>
tag was used to center-align text, images, tables, and other elements on a webpage. For example:
<center>
<h1>Welcome to our website</h1>
<img src="logo.png" alt="Logo">
<p>This is some centered text</p>
</center>
However, it is now recommended to use CSS for centering content. You can use the following CSS code to center-align elements:
<style>
.centered {
text-align: center;
}
</style>
<div class="centered">
<h1>Welcome to our website</h1>
<img src="logo.png" alt="Logo">
<p>This is some centered text</p>
</div>
Main attributes of the <center>
tag:
Attribute | Description |
---|---|
align | Specifies the alignment of content (deprecated) |