本文介绍了XHTML 仍然有害吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在启动一个项目,其中客户要求使用 XHTML 1.0 Strict.现在我想知道 将 XHTML 作为文本/html 认为有害 中描述的问题是否仍然存在以及我是否应该尝试让客户相信这个(非常强烈的)要求会适得其反.

I'm starting a project where the client has mandated the use of XHTML 1.0 Strict. Now I'm wondering whether the problems described in Sending XHTML as text/html Considered Harmful are still current and whether I should try to convince the client that this (very strongly stated) requirement is counterproductive.

Internet Explorer 现在是否正确处理application/xhtml+xml?

Does Internet explorer handle application/xhtml+xml correctly by now?

推荐答案

IE9 处理 application/xhtml+xml,其中包括 SVG,这是想要使用这种媒体类型的主要原因之一.(否则,到目前为止,使用它的意义相对较小,因为您会获得大量脚本更改以及 IE<9 不兼容,因此目前获得的性能提升相对较少.)

IE9 handles application/xhtml+xml, including SVG inside it, one of the main reasons to want to use this media type. (Otherwise, there's relatively little point in using it to date, as you get a bunch of scripting changes, and IE<9 incompatibility, in return for relatively little if any performance gain at the moment.)

我不同意 Hixie 的观点,即以 text/html 的形式提供 XHTML 已经 真的有害.使用 HTML 兼容性指南,XHTML 对自古老的 Netscape 4 以来的任何浏览器都没有问题.使用 XML 处理工具.并且 XML 语法规则比 HTML 更严格但更简单,适合创作;这让验证器有机会发现在 SGML/HTML 中是有效构造的错误,但几乎可以肯定不是你的意思.(另一方面,由于验证器不会强制执行 HTML 兼容性指南,因此它可以在一些地方通过格式良好但麻烦的标记,最常见的是自封闭 标签破坏了整个页面.)

I don't agree with Hixie that serving XHTML as text/html has ever been really harmful. Using the HTML-compatibility guidelines, XHTML poses no problems to any browsers since the ancient Netscape 4. Although it doesn't really get you anything on the client-side, it can be helpful to your own page handling workflow if you're working with XML processing tools. And the XML syntax rules, being stricter-but-simpler than HTML, are a good thing to author to; this gives the validator a chance to pick up on errors that are valid constructs in SGML/HTML but which are almost certainly not what you meant. (On the other hand, since the validator won't enforce HTML-compatibility guidelines there are a couple of places where it can let through well-formed-but-troublesome markup, most commonly self-closed <script> tags breaking the whole page.)

具体来说,回答他的观点:/> 和相关的 SGML 问题只是那些真正相信 HTML 是 SGML 的工具的问题——过去从来没有浏览器.未来,非 XML HTML5 中会明确允许使用.

Specifically, to answer his points: /> and related SGML issues are only a problem to tools that really believe HTML is SGML—which is no browser ever, in the past. In the future, it is specifically allowed in non-XML HTML5.

从旧版"(HTML 3.2 之前!)浏览器中隐藏脚本/样式表已经有十年左右的时间了:我想出了一个被他(正确地)嘲笑为荒谬的错误评论,但它是只是一个练习;我从来没有打算让任何人使用它,除非在一些奇怪的假设紧急情况下.在 XHTML-as-HTML 中使用嵌入式脚本和样式表当然不是必需的"......如果您需要能够包含 //<![CDATA[ hack 就足够了code>< 和 & 字符,更常见的是你甚至不需要它.

Hiding scripts/stylesheets from ‘legacy’ (pre-HTML 3.2!) browsers hasn't been an issue for a decade or so: I came up with the mangled comment hack he (rightly) derides as ridiculous, but it was only an exercise; I never intended anyone to use it except in some strange hypothetical emergency. It's certainly not ‘necessary’ for using embedded scripts and stylesheets in XHTML-as-HTML... a straight //<![CDATA[ hack is enough if you need to be able to include < and & characters, and more commonly you don't even need that.

实际上没有人想要嗅探 XHTML-as-HTML 并以不同的方式对待它,因此整个部分都没有实际意义.将 XHTML 1.1 作为文本/html 发送永远不会好"已被 W3C 更改(毕竟现在很好),XHTML 2.0 已死.

No-one actually wants to sniff for XHTML-as-HTML and treat it differently, so that whole section is moot. "Sending XHTML 1.1 as text/html is NEVER fine" has been changed by W3C (it now is fine after all), and XHTML 2.0 is dead.

是的,如果您愿意,可以使用 XHTML 1.0 Strict、XHTML 1.1 或 XHTML5.但在 IE9 成为您的基准浏览器之前(年龄不会是这种情况),您必须坚持使用 text/html.

So yes, use XHTML 1.0 Strict, or XHTML 1.1 or XHTML5, if you like. But until IE9 is your baseline browser (and that's not going to be the case for ages), you'll have to stick with text/html.

这篇关于XHTML 仍然有害吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 20:31