使用一致行为但已弃用的HTML标记的缺点? [英] Disadvantages of using consistent-behaving yet deprecated HTML tags?

查看:220
本文介绍了使用一致行为但已弃用的HTML标记的缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户访问我的网站时,他们不关心如何完善或标准的编码。他们只关心它是否有效。

When users visit my website, they don't care about how perfect or how much standard the page is coded. They only care about whether it works or not.

有些标签已被弃用,但在所有主要,次要和非常小的浏览器中都具有一致的行为。他们现在正在工作,将在未来工作。 (我不在说 标签,例如< marquee> < blink> 它可能会在未来被删除,因为他们不存在不会打破页面。)我在说的标签是例如:

There are tags that are deprecated but have consistent behavior throughout all major, minor, and very minor browsers. They work now and will work in the future. (I'm not talking about optional tags like <marquee> and <blink> which will probably be removed in the future since their non-existence doesn't break pages.) The tags I'm talking about are for example:


  • < center> (由 google.com homepage,yes and is's May 2014)

  • <center> (used by google.com homepage, yes and it's May 2014)

bgcolor = alink = vlink = link = (所有由 google.com 使用)

<body bgcolor=, alink=, vlink=, link= (all used by google.com)

< font size = (也由 google.com

如果我的HTML生成器生成< body bgcolor = black> 的标签,它将确保在接近100%的用户工作。

If my HTML generator produces tags like <body bgcolor=black>, it is guaranteed to work for near 100% of users.

如果它产生的CSS像 background:black; c $ c>< body bgcolor = black> 。 (从 http://superuser.com/q/732669/78897 http://superuser.com/q/447269 / 78897 ,但我确定他们是不是全世界唯一的。)

If it instead produce CSS like background:black;, it will be supported by lesser users compared to <body bgcolor=black>. (Start with http://superuser.com/q/732669/78897 and http://superuser.com/q/447269/78897, though I'm sure they are not the only ones in the whole world.)

与我一起,这是一个真正的问题,基于一个真正的问题。 将这些标签作为输出有什么真正的缺点?

Bear with me, this is a real question based on a true problem. Exactly what are the real disadvantages of having these tags as output?

推荐答案

p>潜在的缺点包括:

Potential disadvantages include the following:

1)您的客户可能实际上关心代码的标准。也许不是现在,但在未来。也许是有问题的原因,但仍然。

1) Your customer might actually care about how standard the code is. Maybe not now, but in the future. Maybe for questionable reasons, but still.

2)废弃的结构并不总是一致地工作。例如,根据浏览器模式,上的 align = center 属性集可能会有不同的效果。这是一个相对较弱的论点,但是,因为浏览器实践已经在HTML5 CR中描述得很好,你可以管理潜在的问题。 (此外,即使CSS设置可能不一致。)

2) Deprecated constructs do not always work consistently. For example, align=center attribute set on a table may have different effects depending on browser mode. This is a relatively weak argument, though, since the browser practices have been described rather well in HTML5 CR and you can manage the potential problems. (Besides, even CSS settings may work inconsistently.)

3)不能保证未来的所有浏览器都支持已弃用的功能。另一方面,这同样适用于标准特征。实际上,在HTML规范中定义的很少的功能实际上已经从浏览器中删除。 (关于标签,我认为 basefont 是唯一的情况。)所有提到的示例以及 marquee 在HTML5 CR中被描述为过时,但仍然明确定义,根据HTML5 CR,浏览器预期并且部分需要支持它们。

3) There is no guarantee that deprecated features will be supported by all future browsers. On the other hand, the same applies to standard features. In practice, very few features that have been defined in HTML specifications have actually been removed from browsers. (Regarding tags, I think basefont is the only case.) All the examples mentioned, and also marquee, have been described in HTML5 CR as "obsolete" but still well-defined, and according to HTML5 CR, browsers are expected, and partly required, to support them all.

您的同事(设计师/开发人员/ ...)可能会将您的代码(和您)视为老式的,非语义的和其他任何内容。

4) Your colleagues (designers/developers/...) may regard your code (and you) as old-fashioned, non-semantic, and whatever.

5)代码维护并且发展可能更加困难。如果您有1,000页的< body bgcolor = black> ,客户说他们想要一个稍微不同的背景颜色,您需要编辑每个页面。然而,这个论点比看起来弱。首先,这些事情实际发生的频率是多少?第二,如果页面实际上是使用合适的工具生成的,也许你只需要更改一个参数的值并重新生成它们(或者让服务器这样做,如果页面是动态生成的话)。第三,如果你在所有页面上都有一个链接元素,你通常应该参考页面的基本样式表,你只需要在样式表中添加一个规则。很容易用CSS重写显示HTML属性。

5) Code maintenance and development may be more difficult. If you have 1,000 pages with <body bgcolor=black> and the customer says they want a somewhat different background color, you would need to edit each page. This argument is, however, weaker than it seems to be. First, how often do such things actually happen? Second, if the pages have actually been generated using suitable tools, perhaps you just need to change the value of one parameter and regenerate them (or just let servers do that, if the pages are dynamically generated). Third, if you have a link element on all pages, referring to basic style sheet for the pages, as you normally should, you just need to add one rule to that style sheet. It is easy to override presentational HTML attributes with CSS.

总而言之,反对你的方法的实际论据相当弱。最重要的论点与编码风格和原则有关。

To summarize, the practical arguments against your approach are rather weak. The most important arguments relate to coding style and principles.

这篇关于使用一致行为但已弃用的HTML标记的缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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