为什么<中心>标记在HTML中被弃用? [英] Why is the <center> tag deprecated in HTML?

查看:530
本文介绍了为什么<中心>标记在HTML中被弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是很好奇为什么HTML中的< center> 标记被弃用。



< center> 是通过将容器封装在< center> 标记,而且我现在还找不到任何简单的方法。



任何人都知道关于如何集中东西的简单方法(而不是 margin-left:auto; margin-right:auto; 和width thing),取代< center> ?此外,为什么不推荐使用?

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

这篇关于为什么&lt;中心&gt;标记在HTML中被弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆