为什么一些主要网站使用无效的 HTML?

发布于 2024-08-16 22:35:16 字数 172 浏览 4 评论 0原文

我注意到许多网站,甚至是 Google 和一些银行网站,HTML 的编写都很糟糕,属性值周围没有引号,或者在链接中使用了未正确转义的字符(例如&符号)。换句话说,许多人使用无法验证的标记。

我很好奇他们的理由。 HTML 具有简单的规则,但令人难以置信的是它们似乎没有遵循这些规则。或者他们使用的程序只是吐出代码?

I noticed that many websites, even Google and some banking sites, have poorly-written HTML with no quotes around the values of attributes, or using characters such as ampersands not escaped correctly in links. In other words, many use markup that would not validate.

I am curious about their reasons. HTML has simple rules and it is just mind-boggling that they don't seem to follow those rules. Or do they use programs that just spit out the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

第七度阳光i 2024-08-23 22:35:17

大多数人的答案基本上都是正确的——当你每天服务一个页面十亿次时,规则是不同的。字节开始变得重要,当前的压缩级别清楚地表明谷歌关心节省带宽。

几点:

第一,人们暗示谷歌节省带宽的原因是财务原因。不太可能。即使 Google 搜索结果页面每天节省的几 TB 与所有属性的总和相比也只是杯水车薪:Youtube、Blogger、地图、Gmail 等。更有可能的是,Google 想要其搜索结果页面,特别是,尽可能快地在尽可能多的设备上加载。是的,当页面每天加载十亿次时,字节很重要,但当用户在撒哈拉沙漠使用卫星电话并努力获得 1kbps 时,字节也很重要。

第二,XHTML 等的成文标准与自 1994 年以来在每个浏览器中实际运行的事实上的标准之间存在差异。在这里,Google 的规模很重要,因为大多数 Web 开发人员乐于忽略任何麻烦的浏览器只占其用户的不到 0.1%,对于 Google 来说,这 0.1% 可能就是 50 万人。它们很重要。所以他们的搜索结果页面应该可以在 IE 5.5 上运行。这就是他们在许多高价值页面上仍然使用表格进行布局的原因 - 它仍然是在大多数浏览器上“正常工作”的布局。

作为练习,当我在 Google 实习时,我编写了一个完全兼容的 Google 搜索结果页面的 XHTML/CSS 版本并进行了展示。最终问题出现了——为什么我们要提供这种大杂烩的 HTML?我们难道不应该引导网络开发社区朝着标准发展吗?我得到的答案几乎就是上面的第二点。谷歌确实遵循一个标准——不是网络乌托邦的那该多好的标准,而是这个“必须绝对在任何地方都能工作”的现实标准。

Most people have gotten the answer basically right — that the rules are different when you serve a page a billion times a day. Bytes begin to matter, and the current level of compression clearly shows that Google is concerned with saving bandwidth.

A few points:

One, people are implying that Google's reasons for saving bandwidth are financial. Unlikely. Even a few terabytes a day saved on the Google search results page is a drop in the bucket compared to the sum of all their properties: Youtube, Blogger, Maps, Gmail, etc. Much more likely is that Google wants its search results page, in particular, to load as quickly as possible on as many devices as possible. Yes, bytes matter when the page is loaded a billion times a day, but bytes also matter when your user is using a satellite phone in the Sahara and struggling to get 1kbps.

Two, there is a difference between the codified standards of XHTML and the like, and the de-facto standard of what actually works in every browser ever made since 1994. Here, Google’s scale matters because, where most web developers are happy to ignore any troublesome browser that accounts for less than 0.1% of their users, for Google, that 0.1% is perhaps a half million people. They matter. So their search-results page ought to work on IE 5.5. This is the reason they still use tables for layout on many high-value pages – it’s still the layout that “just works” on the greatest number of browsers.

As an exercise, while an intern at Google, I wrote a perfectly compliant XHTML/CSS version of Google’s search result page and showed it around. Eventually the question came up – why are we serving such hodge-podge HTML? Shouldn’t we be leading the web dev community towards standards? The answer I got was pretty much the second point above. Google DOES follow a standard – not the wouldn’t-it-be-nice standards of web utopia, but the this-has-to-work-absolutely-everywhere standard of reality.

巴黎盛开的樱花 2024-08-23 22:35:17

Google 编写糟糕的 HTML 有充分的理由——他们从搜索页面中删除的每个字符每天可能会节省千兆字节的带宽。

Google has a good reason for writing bad HTML – every character they strip from the search page will save them probably gigabytes of bandwidth a day.

罗罗贝儿 2024-08-23 22:35:17

正如之前讨论的,Google 这样做是出于带宽原因。

至于银行和其他企业网站,可能有多种原因 -

  1. CMS 吐出无效的 HTML
  2. Dreamweaver,这已经足够了。
  3. 倾向于使用商业 UI 组件,这些组件甚至可以在古老的浏览器上运行,因此他们会小心谨慎。
  4. 不强调良好的 HTML 和 Javascript 实践。其中许多往往是 Java 或 .NET 商店,没有优秀的 UI 开发人员。
  5. 设计不当的 .NET 用户控件和 JSTL 标记库。

As been discussed previously, google does it for bandwidth reasons.

As for banks and other enterprisey websites, there could be multiple reasons-

  1. CMS spits out invalid HTML
  2. Dreamweaver, enough said.
  3. Tend to use commercial UI components that have been designed to work even on ancient browsers so they err on the careful side.
  4. No emphasis on good HTML and Javascript practices. Many of them tend to be Java or .NET shops with no good UI developers.
  5. Badly designed .NET User controls and JSTL taglibs.
梦明 2024-08-23 22:35:17

对于谷歌等一些网站来说,拥有完美的代码并不“那么”重要。

然而,网页的总大小是。 HTML 代码上节省的几个字节可能意味着数百美元的带宽。

因此,如果他们可以确定他们的页面将正确呈现,他们会毫不犹豫地调整他们的 HTML。

For several websites such as Google, having perfect code is not "that" important.

The total size of the web-page however, is. A few bytes spared on the HTML code can mean hundreds of dollars in bandwidth.

So if they can be certain their page will be rendered correctly, they won't hesitate to tweak their HTML.

幽蝶幻影 2024-08-23 22:35:17

一般来说,编写网站代码很容易,因此对于没有经验或非程序员的进入门槛非常低。这使得生成不合标准的页面变得很容易,并且网络上到处都是这样的页面。将其与 Microsoft Frontpage 等工具结合起来,可以更轻松地创建网站(甚至更容易生成错误的 HTML 代码),您就会遇到糟糕的情况。

Generally speaking, coding up a website is easy and therefore the entry barrier is very low for inexperienced or non programmers. This makes it easy to produce sub standard pages and the web is littered with them. Combine that with tools like Microsoft Frontpage that makes it even easier to make a site (and even easier to generate bad HTML code) and you've got a nasty situation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文