Why is the lt;centergt; tag deprecated in HTML?(为什么是lt;centergt;标签在 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-left和margin-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.
这篇关于为什么是<center>标签在 HTML 中已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么是<center>标签在 HTML 中已弃用?
基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
