Is the center tag still valid?

删除回忆录丶 提交于 2019-12-07 09:07:24

问题


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?


回答1:


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:

The HTML4 spec:

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

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.




回答2:


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

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.

For text aligning use text-align: center;.

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



来源:https://stackoverflow.com/questions/4432410/is-the-center-tag-still-valid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!