Polyglot markup
   HOME

TheInfoList



OR:

In computing, a polyglot markup is a document or script written in a valid form of multiple
markup languages Markup language refers to a text-encoding system consisting of a set of symbols inserted in a text document to control its structure, formatting, or the relationship between its parts. Markup is often used to control the display of the document ...
, which performs the same output, independent of the markup's
parser Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lat ...
, layout engine, or interpreter. In general, the ''polyglot markup'' is a common subset of two or more languages, that can be used as a robust or simplified profile. Polyglot HTML is
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaSc ...
that has been written to conform to both the HTML and
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
specifications.Polyglot Markup: A robust profile of the HTML5 vocabulary
W3C Working Group Note 29 September 2015
A polyglot document can therefore be parsed as either HTML (which is SGML-compatible) or
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
, and will produce the same DOM structure either way. For example, in order for an
HTML5 HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HTML ...
document to meet these criteria, the two requirements are that it must have an HTML5 doctype, and be written in well-formed XHTML. The same document can then be served as either HTML or XHTML, depending on browser support and MIME type.


Polyglot HTML requirements

As expressed by the ''html-polyglot recommendation'', to write a polyglot HTML5 document, the following key points should be observed: # Processing instructions and the XML declaration are both forbidden in polyglot markup # Specifying a document’s character encoding # The DOCTYPE # Namespaces # Element syntax (i.e. End tags are not optional. Use self-closing tags for void elements.) # Element content # Text (i.e. pre and textarea should not start with newline character) # Attributes (i.e. Values must be quoted) # Named entity references (i.e. Only amp, lt, gt, apos, quot) # Comments (i.e. Use <!-- syntax -->) # Scripting and styling polyglot markup The most basic possible polyglot markup document would therefore look like this: The title element must not be empty. In a polyglot markup document non-void elements (such as script, p, div) cannot be self-closing even if they are empty, as this is not valid HTML.Polyglot Markup: HTML-Compatible XHTML Documents: 6.4 Void Elements
W3C Editor's Draft 9 July 2012.
For example, to add an empty textarea to a page, one cannot use instead.


See also

*
Polyglot (computing) In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages or file formats. The name was coined by analogy to multilingualism. A polyglot file is composed by combining syntax from two or more ...


References

{{Reflist


External links

* https://en.wikibooks.org/wiki/Polyglot_markup,_how_to
CSE HTML Validator for Windows with polyglot markup supportBenefits of polyglot XHTML5
HTML Markup languages World Wide Web Consortium standards XML-based standards