From 5a5a4a85bf1cfe783e7009d463aa16368dd5c92f Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 7 Jun 2010 07:17:45 +0200 Subject: [PATCH] Applied leafstorm's html5faq patch --- AUTHORS | 1 + docs/htmlfaq.rst | 185 +++++++++++++++++++++++++++++------------------ 2 files changed, 115 insertions(+), 71 deletions(-) diff --git a/AUTHORS b/AUTHORS index e4f32ace..c3c0e13b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,6 +16,7 @@ Patches and Suggestions - Justin Quick - Kenneth Reitz - Marian Sigler +- Matthew Frazier - Ron DuPlain - Sebastien Estienne - Simon Sapin diff --git a/docs/htmlfaq.rst b/docs/htmlfaq.rst index 21b41b2f..2127afef 100644 --- a/docs/htmlfaq.rst +++ b/docs/htmlfaq.rst @@ -2,66 +2,75 @@ HTML/XHTML FAQ ============== The Flask documentation and example applications are using HTML5. You -will notice that in many situations when end tags are optional they are -not used to keep the HTML cleaner and also faster to load. Because there -is a lot of confusion about HTML and XHTML out there this document tries -to answer some of them. +may notice that in many situations, when end tags are optional they are +not used, so that the HTML is cleaner and faster to load. Because there +is much confusion about HTML and XHTML among developers, this document tries +to answer some of the major questions. -History on XHTML +History of XHTML ---------------- -For a while it looked like HTML was about to be replaced by XHTML. -However barely any websites on the internet are actually real XHTML (which -means XHTML processed with XML rules). There are a couple of reasons why -this is the case. It mostly has to do with Internet Explorer which does -not accept the XHTML mimetype to switch the browser into XML mode. -However this is really easy to bypass but barely anyone does that. This -probably has to do with the fact that XHTML is really painful. +For a while, it appeared that HTML was about to be replaced by XHTML. +However, barely any websites on the Internet are actual XHTML (which is +HTML processed using XML rules). There are a couple of major reasons +why this is the case. One of them is Internet Explorer's lack of proper +XHTML support. The XHTML spec states that XHTML must be served with the MIME +type `application/xhtml+xml`, but Internet Explorer refuses to read files +with that MIME type. +While it is relatively easy to configure Web servers to serve XHTML properly, +few people do. This is likely because properly using XHTML can be quite +painful. -Why is it painful? XML has very strict errorhandling. On a parsing error -the browser is supposed to show the user an ugly error message. Most of +One of the most important causes of pain is XML's draconian (strict and +ruthless) error handling. When an XML parsing error is encountered, +the browser is supposed to show the user an ugly error message, instead +of attempting to recover from the error and display what it can. Most of the (X)HTML generation on the web is based on non-XML template engines (such as Jinja, the one used in Flask) which do not protect you from -accidentally creating invalid HTML. There are XML based template engines -but they usually come with a larger runtime overhead and are not as -straightforward to use because they have to obey XML rules. +accidentally creating invalid XHTML. There are XML based template engines, +such as Kid and the popular Genshi, but they often come with a larger +runtime overhead and, are not as straightforward to use because they have +to obey XML rules. -Now the majority of users assumed they were using XHTML though. The -reasons for that is that they sticked an XHTML doctype on top of the -document and self-closed all necessary tags (``
`` becomes ``
`` or -``

`` in XHTML). However even if the document properly validates -as XHTML there are still other things to keep in mind. +The majority of users, however, assumed they were properly using XHTML. +They wrote an XHTML doctype at the top of the document and self-closed all +the necessary tags (``
`` becomes ``
`` or ``

`` in XHTML). +However, even if the document properly validates as XHTML, what really +determines XHTML/HTML processing in browsers is the MIME type, which as +said before is often not set properly. So the valid XHTML was being treated +as invalid HTML. -XHTML also changes the way you work with JavaScript because you now have -to use the namespaced DOM interface with the XHTML namespace to query for -HTML elements. +XHTML also changed the way JavaScript is used. To properly work with XHTML, +programmers have to use the namespaced DOM interface with the XHTML +namespace to query for HTML elements. History of HTML5 ---------------- -HTML5 was started in 2004 under the name Web Applications 1.0 by the -WHATWG (Apple, Mozilla, Opera) and the idea was to write a new and -improved specification of HTML based on actual browser behaviour instead -of behaviour that exists on the paper but could not be implemented -because of backwards compatibility with the already existing web. +Development of the HTML5 specification was started in 2004 under the name +"Web Applications 1.0" by the Web Hypertext Application Technology Working +Group, or WHATWG (which was formed by the major browser vendors Apple, +Mozilla, and Opera) with the goal of writing a new and improved HTML +specification, based on existing browser behaviour instead of unrealistic +and backwards-incompatible specifications. -For example in theory HTML4 ``Hello`` but because existing websites are using -pseudo-XHTML which uses the Slash in different ways, this could not be -implemented properly. +For example, in HTML4 ``Hello``. However, since people were using +XHTML-like tags along the lines of ````, browser vendors implemented +the XHTML syntax over the syntax defined by the specification. -In 2007 the specification was adopted as the basis of a new HTML -specification under the umbrella of the W3C. Currently it looks like -XHTML is losing traction, the XHTML 2 working group was disbanded and -HTML5 is being implemented by all major browser vendors. +In 2007, the specification was adopted as the basis of a new HTML +specification under the umbrella of the W3C, known as HTML5. Currently, +it appears that XHTML is losing traction, as the XHTML 2 working group has +een disbanded and HTML5 is being implemented by all major browser vendors. HTML versus XHTML ----------------- The following table gives you a quick overview of features available in -HTML 4.01, XHTML 1.1 and HTML5 (we are not looking at XHTML 1.0 here which -was superceeded by XHTML 1.1 or XHTML5 which is barely supported currently): +HTML 4.01, XHTML 1.1 and HTML5. (XHTML 1.0 is not included, as it was +superseded by XHTML 1.1 and the barely-used XHTML5.) .. tabularcolumns:: |p{9cm}|p{2cm}|p{2cm}|p{2cm}| @@ -74,10 +83,10 @@ was superceeded by XHTML 1.1 or XHTML5 which is barely supported currently): +-----------------------------------------+----------+----------+----------+ | ``