I am just curious as to why the
tag in HTML was deprecated.
The
was a simple way of quickly center-aligning b
CSS has a text-align: center
property, and since this is purely a visual thing, not semantic, it should be relegated to CSS, not HTML.
According to W3Schools.com,
The center element was deprecated in HTML 4.01, and is not supported in XHTML 1.0 Strict DTD.
The HTML 4.01 spec gives this reason for deprecating the tag:
The CENTER element is exactly equivalent to specifying the DIV element with the align attribute set to "center".
Food for thought: what would a text-to-speech synthesizer do with <center>
?
You can add this to your css and use <div class="center"></div>
.center{
text-align: center;
margin: auto;
justify-content: center;
display: flex;
}
or if you want to keep <center></center>
and be prepared in case its ever removed, add this to your css
center{
text-align: center;
margin: auto;
justify-content: center;
display: flex;
}
HTML is intended for structuring data, not controlling layout. CSS is intended to control layout. You'll also find that many designers frown on using <table>
for layouts for this very same reason.
The <center>
element was deprecated because it defines the presentation of its contents — it does not describe its contents.
One method of centering is to set the margin-left
and margin-right
properties of the element to auto
, and then set the parent element’s text-align
property to center
. This guarantees that the element will be centered in all modern browsers.