为什么<中心>标记在HTML中被弃用? [英] Why is the <center> tag deprecated in HTML?
问题描述
我只是很好奇为什么HTML中的< center>
标记被弃用。
< center>
是通过将容器封装在< center> $中快速对齐文本和图像块的简单方法c $ c>标记,而且我现在还找不到任何简单的方法。
任何人都知道关于如何集中东西的简单方法(而不是 margin-left:auto; margin-right:auto;
和width thing),取代< center>
?此外,为什么不推荐使用?
一种居中的方法是设置 margin-left
和 margin-right
元素的属性到 auto
,然后将父元素的 text-align
属性设置为 center
。这保证了元素将在所有现代浏览器中居中。
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中被弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!