为什么是<center>标签在 HTML 中已弃用? [英] Why is the <center> tag deprecated in HTML?

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

问题描述

我只是好奇为什么 HTML 中的 <center> 标签被弃用了.

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

<center> 是一种通过将容器封装在 <center> 标记中来快速居中对齐文本和图像块的简单方法,而我现在真的找不到更简单的方法了.

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.

任何人都知道如何将东西"(不是 margin-left:auto; margin-right:auto; 和宽度的东西)居中的任何简单方法,取代 <中心> ?还有,为什么它被弃用了?

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?

推荐答案

<center> 元素已被弃用,因为它定义了其内容的 表示——它确实不描述其内容.

The <center> element was deprecated because it defines the presentation of its contents — it does not describe its contents.

居中的一种方法是将元素的margin-leftmargin-right属性设置为auto,然后设置父元素的 text-align 属性到 center.这保证了元素将在所有现代浏览器中居中.

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;center&gt;标签在 HTML 中已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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