中心标签仍然有效吗?

时间:2021-08-05 20:26:34

I mostly use the HTML <center> tag to center most of my objects. I just wanted to confirm if the tag is still valid or not?

我主要使用HTML

标记来居中大部分对象。我只是想确认标签是否仍然有效?

2 个解决方案

#1


6  

While I agree with the other answers, I don't agree w3schools is a good source for...well, anything really. Look to the specification itself when looking for data:

虽然我同意其他的答案,但我不同意w3schools是一个很好的来源……嗯,真的。在查找数据时,请查看规范本身:

The HTML4 spec:

HTML4规范:

The CENTER element is exactly equivalent to specifying the DIV element with the align attribute set to "center". The CENTER element is deprecated.

中心元素完全等效于指定将align属性设置为“CENTER”的DIV元素。不赞成使用中心元素。

Is it still valid? Nope (but it works, that's a different question), it's been deprecated since HTML4 - semantically it's just not inline with other elements.

它仍然有效吗?没有(但是它可以工作,这是另一个问题),自从HTML4以来,它就被弃用了——从语义上讲,它只是不与其他元素内联。

#2


1  

Valid? As in "this is W3C valid markup"? Yes. (Albeit deprecated).

有效吗?如“这是W3C有效标记”?是的。(尽管弃用)。

Should you use it? No. The <center> tag has no semantic meaning in a web page, and is a styling element par excellence. Use proper CSS alignment and positioning to style your web pages.

你应该使用它吗?不。在web页面中,

标记没有语义含义,是一种卓越的样式元素。使用适当的CSS对齐和定位来样式化你的网页。

For text aligning use text-align: center;.

对于文本对齐使用文本对齐:居中;

For element positioning use auto-width margins: margin-left: auto; margin-right: auto;

对于元素定位,使用自动宽度边距:留白:自动;margin-right:汽车;

#1


6  

While I agree with the other answers, I don't agree w3schools is a good source for...well, anything really. Look to the specification itself when looking for data:

虽然我同意其他的答案,但我不同意w3schools是一个很好的来源……嗯,真的。在查找数据时,请查看规范本身:

The HTML4 spec:

HTML4规范:

The CENTER element is exactly equivalent to specifying the DIV element with the align attribute set to "center". The CENTER element is deprecated.

中心元素完全等效于指定将align属性设置为“CENTER”的DIV元素。不赞成使用中心元素。

Is it still valid? Nope (but it works, that's a different question), it's been deprecated since HTML4 - semantically it's just not inline with other elements.

它仍然有效吗?没有(但是它可以工作,这是另一个问题),自从HTML4以来,它就被弃用了——从语义上讲,它只是不与其他元素内联。

#2


1  

Valid? As in "this is W3C valid markup"? Yes. (Albeit deprecated).

有效吗?如“这是W3C有效标记”?是的。(尽管弃用)。

Should you use it? No. The <center> tag has no semantic meaning in a web page, and is a styling element par excellence. Use proper CSS alignment and positioning to style your web pages.

你应该使用它吗?不。在web页面中,

标记没有语义含义,是一种卓越的样式元素。使用适当的CSS对齐和定位来样式化你的网页。

For text aligning use text-align: center;.

对于文本对齐使用文本对齐:居中;

For element positioning use auto-width margins: margin-left: auto; margin-right: auto;

对于元素定位,使用自动宽度边距:留白:自动;margin-right:汽车;