What is a polyglot document?
In this answer to this question, Lachlan-Hunt writes the following:
With HTML5, you can choose to use HTML-only syntax, meaning that it is only compatible with being served and processed as text/html it is not well-formed XML. Or use XHTML-only syntax, meaning that is is well-formed XML, but uses XML features that are not compatible with HTML. Or, you can write a Polyglot document , which is conforming and compatible with both HTML and XHTML processing (In principle, this is conceptually similar to writing XHTML 1.0 that conforms with Appendix C guidelines).
What is a Polyglot document?
A polyglot program is a program that is valid in more than one language. See http://en.wikipedia.org/wiki/Polyglot_(computing).
A polyglot (person) is someone who is fluent in many languages.
So the polyglot document in this case is both valid HTML and XHTML.
Apparently the word derives from the Ancient Greek πολύγλωττος (poluglōttos, “'many-tongued, polyglot'”), from πολύς (polus, “many”) + γλῶττα (glōtta, “'tongue, language'”)
See the explanation in the HTML 5 Reference: http://dev.w3.org/html5/html-author/#polyglot-documents
A polyglot HTML document is a document that conforms to both the HTML and XHTML syntactic requirements, and which can be processed as either by browsers, depending on the MIME type used. This works by using a common subset of the syntax that is shared by both HTML and XHTML.
Polyglot documents are useful to create for situations where a document is intended to be served as either HTML or XHTML, depending on the support in particular browsers, or when it is not known at the time of creation, which MIME type the document will ultimately be served as.
In order to successfully create and maintain polyglot documents, authors need to be familiar with both the similarities and differences between the two syntaxes. This includes not only syntactic differences, but also differences in the way stylesheets, and scripts are handled, and the way in which character encodings are detected.
Poly glot comes from the greek meaning many tongues. Tongue in this case means language. So a polyglot person is a person who speakes many languages.
A polyglot document in this case is a document which "speaks" XHTML and HTML. So to an XHTML parser it looks perfectly formed, and it also looks perfectly formed to an HTML parser.
链接地址: http://www.djcxy.com/p/89020.html上一篇: DOCTYPE会影响线条的渲染
下一篇: 什么是多边形文档?