HTML Center Tag

This article discusses Html Center Tag. It would satisfy the requirements for learning.

The <center> tag in HTML was once commonly used to horizontally center content on a web page. However, it has been deprecated in HTML5 and is no longer recommended for use.

The reason for deprecating the <center> tag is that it separates the presentation of the content from its structure and semantics, which goes against the principles of modern web design. Instead, it is recommended to use CSS to control the layout and alignment of content on a web page.

Use of HTML Center Tag

The <center> tag was typically used to center content such as text, images, and other elements within a web page.

That would result in the content being centered horizontally within the page.

The given example shows how we can center a picture and a text using the <center> tag:

Example: 

<!DOCTYPE html> <html><body><br><br><br><br><br><center> <br><br><p>This Text and the picture below is in center of the page </p><br><img src="https://mrexamples.com/wp-content/uploads/2023/03/flower-scaled.jpg" width="250px" height="200px"><br><br><br></center> <br><br> </body></html>

But now, the same task could be done efficiently using the CSS align center property:

Align text in the center using CSS:

Example

<!DOCTYPE html> <html> <head> <style> h1 {text-align: center;} p {text-align:center;} div {text-align: center;} </style> </head> <body> <h1>This is capital heading tag using h1</h1> <p>This simple text using the paragraph tag</p> <div>This is a div.</div> </body> </html>


Incompatible with HTML5

In HTML4, text was centered using the <center> Center Tag .


If this article somehow helped you to meet your educational goal or to learn something innovative, then do share this article with your friends by clicking on the links below.
We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *