Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Polyglot (computing)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Polyglot markup=== '''Polyglot markup''' has been proposed as a useful combination of the benefits of [[HTML5]] and [[XHTML]].<ref name="w3c">{{cite web |title=Polyglot Markup: A robust profile of the HTML5 vocabulary |url=https://www.w3.org/TR/html-polyglot/ |access-date=4 September 2022 |archive-date=9 August 2022 |archive-url=https://web.archive.org/web/20220809042911/https://www.w3.org/TR/html-polyglot/ |url-status=live }}</ref> Such documents can be parsed as either HTML (which is <span style="white-space:nowrap">[[SGML]]-compatible</span>) or [[XML]], and will produce the same [[Document Object Model|DOM]] structure either way. For example, in order for an [[HTML5]] document to meet these criteria, the two requirements are that it must have an HTML5 [[Document Type Declaration|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. As expressed by the ''html-polyglot recommendation'',<ref name="w3c" /> 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:<ref name="w3c" /> <syntaxhighlight lang="html"> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> <head> <title>The title element must not be empty.</title> </head> <body> </body> </html> </syntaxhighlight> In a polyglot markup document non-void elements (such as <code>script</code>, <code>p</code>, <code>div</code>) cannot be self-closing even if they are empty, as this is not valid HTML.<ref>[http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html#empty-elements Polyglot Markup: HTML-Compatible XHTML Documents: 6.4 Void Elements] {{Webarchive|url=https://web.archive.org/web/20121002041508/http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-authoring-guide.html#empty-elements |date=2 October 2012 }}. W3C Editor's Draft 9 July 2012.</ref> For example, to add an empty textarea to a page, one cannot use <code><nowiki><textarea/></nowiki></code>, but has to use <code><nowiki><textarea></textarea></nowiki></code> instead.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)