不推荐使用Align属性 [英] Align Attribute Deprecated

查看:229
本文介绍了不推荐使用Align属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不久前,我发现中心标签已被弃用。这是可以理解的,因为HTML是用于结构化内容,而不是用于格式化。但是为什么也不赞成使用align属性呢?属性可以用于格式化。我知道可以使用CSS,但并非所有人都知道CSS。更糟糕的是, text-align:center; margin-left:auto; margin-right:auto; 并不总是将对象居中,但总是可以使用很多对象。

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.

这里是W3C的帖子: http://www.w3.org/TR/html4/present /graphics.html#h-15.1.2

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

在与我合作的网站上,我们使用的是最新的doctype()。我应该尽力不使用align属性吗? CSS是使对象居中的唯一安全方法吗?我正在尝试确保内容在将来是安全的。

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.

推荐答案

是的,应该使用CSS。我想不出一个单独的原因,为什么使用HTML属性而不是CSS规则进行对齐会更好。而且,如果您不想学习CSS(很好),则可能要考虑使用CSS框架,例如 Twitter Bootstrap ,尤其是支架部分。这样可以节省大量时间,从一开始就使您的网站看起来不错,并且让您在厌倦了默认主题时以一致的方式应用自定义主题。

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.

这篇关于不推荐使用Align属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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