Align Attribute Deprecated

空扰寡人 提交于 2019-12-23 20:58:43

问题


I found out a while back that the center tag was deprecated. Understandable because HTML is meant for structuring content and not so much for formatting. But why is the align attribute deprecated too? Attributes can be used for formatting. I understand that CSS can be used, but not everyone knows CSS. And to make it worse, text-align:center; and margin-left: auto; margin-right: auto; doesn't always center objects, but using pretty much always works.

Here's the Post from the W3C on this: http://www.w3.org/TR/html4/present/graphics.html#h-15.1.2

On a site I'm working with we are using the latest doctype (). Should I try my best not to use the align attribute? Is CSS the only safe way to center objects? I'm trying to make sure content is secure for the future.


回答1:


Yes, CSS should be used for that. I can't think of a single reason why it would be better to use an HTML attribute for alignment instead of a CSS rule. And if you don't want to learn CSS (which is fine), you might want to consider using a CSS framework like Twitter Bootstrap, especially the scaffolding part. It will save you a ton of time, make your site look good from the get go, and let you apply custom themes in a consistent fashion whenever you grow tired of the default one.



来源:https://stackoverflow.com/questions/14551305/align-attribute-deprecated

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