Why is the <center> tag deprecated in HTML?

I am just curious as to why the <center> tag in HTML was deprecated.

The <center> was a simple way of quickly center-aligning blocks of text and images by encapsulating the container in a <center> tag, and I really cannot find any simpler way on how to do it now.

Anyone know of any simple way on how to center "stuff" (not the margin-left:auto; margin-right:auto; and width thing), something that replaces <center> ? And also, why was it deprecated?


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.


HTML is all about providing structure and meaning to content, and this should be its sole function .

However, there are assorted tags that were added in the past by stupid browser developers, which violate this basic principle.

At some point, people came to their senses (partially, at least), and started (trying to) agree upon a specification for writing correct HTML, so they deprecated some of these tags.

However, the damage has already been done - too many people have learnt HTML as "put tags around stuff and stuff happens", rather than understanding the (important and useful) distinction between semantics and presentation, and those people have gone on to write books and tutorial, teaching other people the wrong way to write HTML, who themselves have done the same, and we've ended up with a right old mess.

Ideally, the center tag should never have existed, because people should have pointed out it's not 'real' HTML, and told the browser makers to go back and do it properly.


And for doing it properly... alignment is of course a presentation issue - applying layout and formatting to (structured) content - and the language to use for that is CSS .

However, yet again, stupid browser developers screwed up early CSS - and in many cases people creating web pages had to use incorrect HTML because the CSS simply didn't work.

These days, we're starting to get some useful functionality added to CSS, but there's still a lot that isn't implemented, and quite a few things that could have been implemented in far superior ways, but are now standardised so we're stuck with the old ways.

If stylesheets had been implemented by sensible people, you'd have all the controls you have in any decent office software - for aligning blocks and text, it'd work horizontally, vertically, upside-down, rotated, and so on - and it wouldn't be done in the stupid way of setting left/right margins to auto.


I'll add quickly, for completeness, the third 'level' for web pages, which deals with adding interactivity to an otherwise static page, which is of course the (mis-named) JavaScript .

Yet again, those stupid browser developers didn't know what they were doing. They picked an utterly inaccurate/invalid name (for marketing reasons), and again riddled a potentially great and powerful language with flaws, lack of functionality, and created something that was (until recently) hated by many people.

We have of course in the past few years seen a large uprising of JavaScript libraries which have helped to show some of the cool stuff JS has been capable of for years, hidden away many of the browser flaws which still exist in the browsers, and have partially helped to patch up CSS support so it's a bit more useful (still lots of things missing though).


So yeah, to summarise all that , the ultimate answer is because browser makers were stupid. :)


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".

链接地址: http://www.djcxy.com/p/15652.html

上一篇: 为什么TR不采取风格?

下一篇: 为什么HTML中不赞成使用<center>标签?