开发者

What is so bad about the center tag?

开发者 https://www.devze.com 2023-02-07 21:58 出处:网络
Yep, W3 says it\'s (<center>) deprecated... But all browsers support it (including new rel开发者_如何学Ceases)...

Yep, W3 says it's (<center>) deprecated... But all browsers support it (including new rel开发者_如何学Ceases)...

Can anyone shed some light on this, everyone says "It's bad/frowned upon." yet I've seen no evidence..

PLEASE READ THE QUESTION, IT'S NOT A DUPLICATE:

I was asking why this is bad/frowned upon, not why it's been deprecated!!

Edit:

So, the only reason is that "The CSS should handle this"?


The issue is not that it is "bad". It a matter of separation of concerns.

This tag is intended to be used for presentation only. It has no other semantic meaning.

Since the move is to have presentation handled by CSS and HTML should only be used for semantic markup, the tag has been deprecated.


The problem is its not semantic (which means it isn't describing the data is, but instead what to do with it).

HTML is meant to be semantic - its markup after all. Does XML describe how each of its nodes should be viewed? Neither should HTML, thats what stylesheets are for.

Its about separation of concerns at the end of the day - the more separation the less spaghetti soup of code you create and the more chance that what you write can be reused.


As <i> or <b>, those tags got nothing semantic. It's just style which should be handled with CSS and not HTML.


Since a long time, W3C encourages everyone, any developer and Web browser implementations to enforce CSS for defining the style of HTML, XHTML layouts.

That's "center" element defines how some content must be presented, while XHTML/HTML must define "the document" - the meaning, semantics -, never "how to show content". This is CSS role.

This tag is supported for backwards compatibility, but no one should be using in new Web developments, even knowing that CSS is easy but sometimes centering some part of a layout needs advanced styling skills.


It defines the presentation of its contents instead of describing them. And presentation and data should be split.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号