I am just curious as to why the tag in HTML was deprecated.
The was a simple way of quickly center-aligning b
center is one of them;center tag is not the same as a div with text-align:center;Let me explain because there are notorious downvoters here who will think I'm defending oldschool HTML4 or something. No I'm not. But the debate around center is simply a trend war, there is no real reason to ditch a tag that serves a valid purpose well.
So let's see the major arguments against it.
"It describes presentation, not semantics!"
No. It describes a logical arrangement - and yes, it has a default appearance, just as other tags like or do. But the point is the enclosed part's relation to its surroundings. Center says "this is something we separate by
visually different positioning".
"It's not valid"
Yes it is. It's just deprecated, as in, could be removed later. For 15+ years now. And it's not going anywhere, apparently. There are major sites that use this tag because it's very readable and to the point - and those are the same reasons we like HTML5 tags for.
"It's not supported in HTML5"
It's one of the most widely supported tags, actually. MDN says "its use is discouraged since it could be removed at any time" - good point, but that day may never come, to quote a classic. Center was already deprecated in like 2004 or so - it's still here and still useful.
"It's oldschool"
Shoelaces are oldschool too. New methods don't invalidate the old. You want to feel progressive and modern: fine. But don't make it the law.
"It's stupid / awkward / lame / tells a story about you"
None of these. It's like a hammer: one tool for a specific job. There are other tools for the same job and other jobs for the same tool; but it was created to solve a certain problem and that problem is still around so we might as well just use a dedicated solution.
"You shouldn't do this, because, CSS"
Centering can absolutely be achieved by CSS but that's just one way, not the only one, let alone the only appropriate one. Anything that's supported, working and readable should be ok to use. Also, the same argument happened before flexboxes and CSS grids, which is funny because back then there was no CSS way to achieve what center did. No, text-align:center is not the same. No, margin:auto is not the same. Anyone who argued against center tags before flexbox simply didn't know enough about CSS.
The only reason not to use
is because people will hate you.