为什么 Google 主页使用已弃用的 HTML(即无效的 HTML5)?
我在 Firebug 中查看 www.google.com
并注意到一些奇怪的事情:Google 徽标使用中心标记居中。
所以我去检查了页面 W3C 验证器 发现 48 个错误。 现在,我知道有时您无法使页面有效,尤其是当我们谈论 www.google.com
之类的内容并且您希望它尽可能小时,但是有人可以解释一下为什么他们使用中心标签吗?
I was looking at the www.google.com
in Firebug and noticed something odd: The Google logo is centered using a center tag.
So I went and checked the page with the W3C validator and it found 48 errors. Now, I know there are times when you can't make a page valid, especially when we're talking about something like www.google.com
and you want it to be as small as possible, but can someone please explain why they use the center tag?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
几年前,我参加了 SXSW 的一个名为“F*ck Standards”的小组,该小组的主题是在有意义的情况下打破标准。 小组中有一位谷歌工程师谈到谷歌主页验证失败、使用不推荐使用的标签等问题。他说这一切都与性能有关。 在本例中,他特别提到了使用表格进行布局渲染,优于 div 和 CSS。 只要页面对用户有用,他们就会更看重性能而不是标准。
这是一个非常简单的页面,流量很高,所以很有意义。 我想如果您正在构建一个复杂的应用程序,那么这种方法可能无法很好地扩展。
从马嘴里说出来。
I attended a panel at SXSW a few years ago called "F*ck Standards" which was all about breaking from standards when it makes sense. There was a Google engineer on the panel who talked about the Google home page failing validation, using deprecated tags, etc. He said it was all about performance. He specifically mentioned layout rendering with tables beating divs and CSS in this case. As long as the page worked for their users, they favored performance over standards.
This is a very simple page with high traffic so it makes sense. I imagine if you're building a complex app that this approach might not scale well.
From the horse's mouth.
因为这是完成工作最简单、最简洁的方法。 当然,
已被弃用,但只要它仍然受支持,您可能仍然会看到他们使用它。
Because it's just the easiest, most concise way to get the job done.
<center>
is deprecated, for sure, but as long as it's still supported, you're likely to still see them using it.小于边距:0 自动。 解析速度更快。 它是有效的 HTML4。 没有外部依赖,因此 HTTP 请求更少。
Shorter than margin:0 auto. Quicker to parse. It is valid HTML4. No external dependencies, so less HTTP requests.
可用性不是有效性。
Google 搜索最大的成就是建立了一个易于使用且可广泛使用的网站。 现在,如果谷歌通过一个未经验证的页面实现了这一点,那么,就有一个值得学习的教训。
Usability is NOT validity.
Google Search's biggest achievement has been to build a site which is easy to use, and can be widely used. Now, if Google achieved this with a page which does not validate, well, there's a lesson there to learn.
我认为更好的问题是“为什么谷歌要验证它是否工作正常?” 这对用户来说没有区别。
I think a better question to ask would be "why would Google make it validate if it works fine?" It makes no difference to the user.
有猜测和讨论这是否是故意的; 在第一个链接中进行的基本测试确实会产生更小的页面,甚至通过理论上累积的数百万页面浏览量进行压缩。 但我怀疑这就是原因:它被创建,当时在许多浏览器上进行了测试,它有效,并且继续有效。
There has been speculation and discussion about whether this is intentional; the basic test carried out in the first link does result in a smaller page, and even gzipped, through millions of page views it theoretically stacks up. I doubt that's the reason though: it was created, tested on many browsers at the time, it worked, and continues to work.
谷歌在其主页上以多种方式破坏了验证。 很可能真正的原因是——它们都与速度和带宽成本有关。 查看主页 HTML 的大小,特别是在数据包级别应用 Gzip 后。 他们显然是在试图避免数据包碎片(这意味着更多的带宽),并愿意不惜一切代价来获得它(标识符缩短、引号删除、不推荐使用的标签、空白删除等。
如果您将此视为有效性问题,很好,但是他们故意违反了规则,如果你不这么认为,你当然可能会得出否定的结论,顺便说一句,你可以以积极和消极的方式进一步优化他们的页面,但为什么一次。在典型的数据包大小内,这有点毫无意义。
Google's breaks validation in many ways on their home page. The very likely real reason - they are all about speed and bandwidth costs. Look at the size of the home page HTML particularly after Gzip is applied at the packet level. They are clearly trying to avoid packet fragmentation (which will mean more bandwidth) and willing to do whatever it takes to get it (identifier shortening, quote removal, deprecated tags, white space removal, etc.
If you look at this just as a validity question, fine but they break the rules on purpose if you don't assume this of course you may jump to a negative conclusion. BTW you can further optimize their pages both in positive and negative manners but why once inside the typical packet size it is somewhat pointless.
他们还使用其他已弃用的表示标签,例如 font 和 u。 我的猜测是,它使页面加载速度比使用外部样式表更快,并允许它在更多平台上工作。
They also use other deprecated presentational tags like font and u. My guess is it makes the page quicker to load then using an external stylesheet and allows it to work on more platforms.
当然,它已被弃用,但我认为简单性就是您问题的答案。
It's deprecated, sure, but I think simplicity is the answer to your question.