{"id":100,"date":"2005-12-05T10:05:20","date_gmt":"2005-12-05T10:05:20","guid":{"rendered":"http:\/\/lachy.id.au\/log\/2005\/12\/xhtml-is-not-for-beginners"},"modified":"2006-04-30T23:26:27","modified_gmt":"2006-04-30T23:26:27","slug":"xhtml-beginners","status":"publish","type":"post","link":"https:\/\/lachy.id.au\/log\/2005\/12\/xhtml-beginners","title":{"rendered":"XHTML is not for Beginners"},"content":{"rendered":"<p>\tAs web standards advocates, many of us participate in numerous online communities\r\n\tsuch as mailing lists, forums, newsgroups and even blogs (both our own and\r\n\tcomments on others). In these communities, we often encounter beginners who\r\n\tare either just starting out with HTML, or have been doing HTML for a while,\r\n\tbut are new to the concept of developing with standards.<\/p>\r\n<p>Invariably, such beginners face the eternal question of HTML or XHTML; and\r\n\ttoday, I intend to answer this question (as it applies to beginners) once and\r\n\tfor all. For experienced users, the answer may be different, this only applies\r\n\tto beginners and to those of us teaching them.<\/p>\r\n<p>I don\u2019t particularly want to start up the XHTML vs. HTML debate again, nor\r\n\tsimply reiterate that XHTML as text\/html is extremely harmful; and I must stress\r\n\tthat both HTML and XHTML have their uses and it\u2019s important to use the right\r\n\ttool for the job. But for beginners, there needs to be a clear answer with a\r\n\tclear learning path, and those of us teaching them need to be united in our\r\n\tposition. For if beginners are hearing different answers from different parties,\r\n\tonly confusion will result and we may end up losing them to dark side of the\r\n\tforce forever.<\/p>\r\n<p>Let me start off by saying that XHTML is not for beginners. We must start\r\n\twith HTML and have a clear learning path towards the future with XHTML. It\r\n\thas been argued, that since <a href=\"http:\/\/lachy.id.au\/log\/2005\/04\/xhtml-future\">the\r\n\tfuture lies with XHTML<\/a> (although that is yet to be\r\n\tseen), we should be teaching XHTML from the ground up. That sounds nice in\r\n\ttheory, but the reality is that we\u2019re still teaching in a predominately <code>text\/html<\/code> environment,\r\n\tand the fact is: trying to teach XHTML under HTML (tag-soup) conditions is\r\n\tlike trying to teach a child to swim by throwing them in the deep end and\r\n\tnot realising they&#8217;re drowning until it&#8217;s too late. When it comes to XHTML:\r\n\tthere is far too much for a beginner to learn, not to mention the significant\r\n\tissues of browser support, that we must simply accept that they\u2019re not ready\r\n\tand teach them HTML instead.<\/p>\r\n<p>XHTML is not merely HTML 4 in XML syntax, it comes packaged with all the XML\r\n\thandling requirements as well, with great big \u201c<em>Fragile<\/em>\u201d and \u201c<em>Handle\r\n\twith Care<\/em>\u201d\r\n\tstickers on the front of the box. Despite all the myths surrounding the ability\r\n\tto use XHTML as <code>text\/html<\/code> and then simply make the switch to XML when browser\r\n\tsupport improves, there is significant evidence to show that XHTML developed\r\n\tin a <code>text\/html<\/code> environment will not survive the transition to XML.<\/p>\r\n<p>The sheer number of tag-soup pages claiming to be XHTML are a direct result\r\n\tof pushing it upon newcomers while leaving out all the extremely important\r\n\tdetails, most of which they won\u2019t understand yet anyway, but do actually\r\n\tneed to learn before using it. I won\u2019t go into the details here, but these\r\n\tissues with XHTML include, among others, the following; and I guarantee that\r\n\tif you ask a beginner (who learned XHTML under HTML conditions) about\r\n\tany of them, they\u2019ll look at you blankly, without a clue what your talking\r\n\tabout.<\/p>\r\n<h3>General Markup Issues <\/h3>\r\n<ul>\r\n\t<li>Internet Explorer 7 and below do not support XHTML at all, not even limited\r\n\t\tsupport. Anyone who says otherwise is either <em>ignorant<\/em> or <em>lying<\/em>.\r\n\t\t(It is expected, but not guaranteed, that IE8 will finally support it).<\/li>\r\n\t<li> Well-formedness errors are <em>fatal<\/em>.<\/li>\r\n\t<li>The namespace (<code>xmlns<\/code> attribute) must be declared in the root element, despite\r\n\t\tthe validator not issuing an error if it&#8217;s omitted.<\/li>\r\n\t<li>Use of named entity references may be fatal for non-validating parsers\r\n\t\t(except for <code>amp<\/code>, <code>lt<\/code>, <code>gt<\/code>, <code>quot<\/code> and <code>apos<\/code>).<\/li>\r\n\t<li>Use <code>xml:lang<\/code> instead of <code>lang<\/code>.<\/li>\r\n\t<li>The meaning of the XML empty element syntax has a different meaning in\r\n\t\tSGML and HTML, though browsers don\u2019t support it.<\/li>\r\n\t<li>DTDs do not support validation of mixed namespace documents very well.<\/li>\r\n\t<li>When served as XML, the <code>DOCTYPE<\/code> is not required to trigger standards\r\n\t\tmode in browsers.<\/li>\r\n\t<li>The XML declaration will trigger quirks mode in IE6 when served as <code>text\/html<\/code>,\r\n\t\tit should be omitted in such cases (but see the next few points).<\/li>\r\n<\/ul>\r\n<h3>MIME and Encoding<\/h3>\r\n<ul>\r\n\t<li>MIME type must be declared appropriately in the HTTP headers (<code>application\/xhtml+xml<\/code>\t\t(preferred), <code>application\/xml<\/code> (acceptable) or <code>text\/xml<\/code> (not recommended)).<\/li>\r\n\t<li>Encoding should be declared within the XML declaration, rather than the\r\n\t\tHTTP headers, since XML is a self describing format. (This does not apply to\r\n\t\t<code>text\/xml<\/code>).<\/li>\r\n\t<li>For <code>text\/xml<\/code>, unless specified at the protocol level, <code>US-ASCII<\/code> must\r\n\t\tbe used.<\/li>\r\n\t<li>When the XML declaration is omitted, <code>UTF-8<\/code> or <code>UTF-16<\/code> must be used, unless\r\n\t\tspecified in a higher level protocol.<\/li>\r\n\t<li>The <code>meta<\/code> element is is useless for specifying the character encoding and\r\n\t\tMIME type.<\/li>\r\n<\/ul>\r\n<h3>Scripts and Stylesheets<\/h3>\r\n<ul>\r\n\t<li><code>script<\/code> and <code>style<\/code> elements are parsed differently, the traditional <a href=\"http:\/\/lachy.id.au\/log\/2005\/05\/script-comments\">HTML\r\n\t\t\tcomment-like syntax within script and style elements<\/a> must not be used for the purpose\r\n\t\tof hiding from obsolete browsers.<\/li>\r\n\t<li><code>document.write()<\/code> and <code>document.writeln()<\/code> do not work.<\/li>\r\n\t<li><code>innerHTML<\/code> (non-standard property) is not supported by some XHTML UAs.<\/li>\r\n\t<li>DOM requires the use of namespace aware methods, where applicable.<\/li>\r\n\t<li>DOM methods are case sensitive.<\/li>\r\n\t<li>Element and attribute names from DOM methods are exposed case sensitively\r\n\t\t(lowercase), compared with uppercase in HTML.<\/li>\r\n\t<li>XML rules for CSS Stylesheets are applied and they differ significantly\r\n\t\tfrom HTML rules. e.g. No special treatment for the <code>body<\/code> element. <\/li>\r\n\t<li>Case sensitivity of CSS selectors depends on the markup language, and are\r\n\t\tthus case sensitive for XHTML.<\/li>\r\n<\/ul>\r\n<p>I\u2019m quite sure that isn\u2019t a complete list of\r\n\tdifferences between HTML and XHTML, but each and every one of them (plus\r\n\tany that I\u2019ve missed) needs to be learned by anyone who is learning XHTML properly.<\/p>\r\n<p>The vast majority of those do not apply, or are at least not exposed well,\r\n\tunder HTML conditions. Therefore, because of all of this and the\r\n\tfact that most beginners will be learning under HTML conditions, XHTML is\r\n\tnot safe for beginners to learn. By teaching XHTML to beginners, we\u2019re really\r\n\tonly teaching a new form of tag soup under the guise of \u201cstandards based\r\n\tdevelopment\u201d and it is doing significantly more harm than good.<\/p>\r\n<p>Experienced users who are competent enough to understand all of these issues\r\n\tand make an informed decision about whether to use HTML or XHTML may do so,\r\n\tbut we cannot expect the same from beginners. So, let me reiterate that we must\r\n\tbe united on this issue and we must encourage beginners to start with HTML,\r\n\tnot XHTML.<\/p>","protected":false},"excerpt":{"rendered":"Trying to teach XHTML under HTML conditions is like trying to teach a child to swim by throwing them in the deep end and not realising they&#8217;re drowning until it&#8217;s too late.","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,7],"tags":[],"_links":{"self":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/posts\/100"}],"collection":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":0,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"wp:attachment":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}