Beginners should start with HTML, not XHTML

There are many more differences between HTML and XHTML than most web developers who use XHTML realise. The differences go beyond just closing all elements, quoting all attribute values, and using lower case for all element and attribute names. Because of the pitfalls involved in using XHTML, Lachlan Hunt claims that XHTML is not for Beginners

I tend to agree. I’ve seen experienced web developers who know HTML very well have problems getting XHTML right. And that is while serving XHTML as text/html. When you start serving XHTML as application/xhtml+xml things get way more complicated, as Lachlan points out in his article and as I do in The perils of using XHTML properly.

Posted on December 6, 2005 in (X)HTML, Quicklinks

Comments

  1. It definitely is more complicated (and you can’t get AdSense working because of a lack of document.write() support), but I have a hard time with the idea of beginners learning to use HTML instead of XHTML because they’ll be learning in far too lenient an environment. They’ll be making all kinds of mistakes and it’ll be “okay”.

  2. I’ll have to disagree with you on this one. I myself started off with XHTML, I’m not completely fluent, and I occasionally do get stuck on why some things happen, but it ultimately leads to my better understanding of the language. Plus there’s always online help and such.

    -Betta

  3. I also learned XHTML when I first started, and for anyone starting out I would recommend the same. The reasons given in the article don’t seem to amount to much when you consider the benefits of starting things right and not developing bad habits. My two cents.

  4. When I really got interested in web development , XHTML was actually my starting point.

    Then it took me two years to realize that what I was doing was too much work when compared to the outcome (content neogation and such), so I migrated back to HTML. I still use HTML, and simply love where its headed.

  5. I disagree. Three years back, when my 10 year old neice asked me how she could make a website, I taught her basic XHTML + CSS in just about an hour or so. She didn’t mess up or get confused. She didn’t know HTML ever. She never needed it.

    I theorize that it’s those who’ve been taught HTML for so long and have it stuck in their head and are set in their ways, that have the hard time.

    (i should point out that my neice has forgotten it all over the past couple years, because she just never needed to code and her interests wandered on to other things in life)

  6. Half to poke a little fun at this topic, and half because the XHTML vs. HTML battle rages on, I decided to create a dedicated Yahoo! group and mailing list.

    You can read my post on it on my blog at XHTML vs. HTML, or go directly and join the list at XHTML_vs_HTML@yahoogroups.com.

  7. What is there to discuss?

    XHTML (as application/xhtml+xml) has strict rules - HTML does not. HTML rely on recovery in all browsers. XHTML (as application/xhtml+xml) provides no recovery to rely on.

    Pick and choose depending on what you like and what you think you can master. Then learn how to avoid relying on any recovery, and you get it right regardless of whether it is HTML (text/html) or XHTML 1.0 (text/html or application/xhtml+xml) you’re serving those browsers.

    The problem lies in what others can inject. If that is a problem than either fix the problem from the start, or stick with HTML and recovery until it is fixed.

  8. December 7, 2005 by Derek

    I don’t know… I don’t consider myself to be a particularly intelligent or skillful web developer but I just don’t find it all that hard to comprehend HTML, XHTML, or their differences. There’s a simple to use validator for both and there specifications are pretty easy to read.

    I can’t help but laugh when I read HTML vs XHTML entries, which seem plentiful these days. It’s like web developers like to make enourmous mountains out of moderately sized mole hills. XHTML, HTML, whatever. Just keep it valid.

  9. As a teacher I use XHTML. I want the students to learn XHTML right away - it would seem wrong to learn them HTML and then say “Hey, there’s a more recent version with stricter rules that you could have learned instead and probably is a more sought after amongst employers(?)”.

    It also seems easier to teach since they have to create wellformed code etc. to be approved.

  10. Whan you teach or just use XHTML do you teach about application/xhtml+xml too? That the server has to send the MIME type, typing it in the META tag just wont do it. But you dont even use application/xhtml+xml in your META tag do you?

    I tok a look at the sites of you XHTML fanboys, and I didn’t see ONE that was served as application/xhtml+xml. And then its parsed as crappy HTML. So whats the gain then? Then you too rely on the browsers ability to fiks problems.

    I also see no problem in writing semantik and structured kode in HTML 4.01, you have the option to ommit sertain tags(HTML, HEAD, BODY, /P, /LI, ect), but you dont HAVE TO. When learing something, do it right, XHTML 1.0 will never be right today.

  11. My site’s served as application/xhtml+xml, Sebastian. You can find about 50 more linked from “The X-Philes”, although that list hasn’t been updated in over a year.

    Personally, although my site is written in XHTML, and served as application/xhtml+xml, I’m of the opinion that as long as what you write is valid and semantic there’s no problem at all with using HTML. In fact, I don’t really see too many benefits to using XHTML in the first place. As such, most of the sites I’m writing at the moment use 4.01 strict.

  12. I started with XHTML then learnt HTML 4.01. I mean, when I was beginning to properly “learn” rather than doing only a couple of hours per month experimenting with generic HTML…

  13. For those who have commented to say that either they learned XHTML as beginners or taught XHTML to beginners, I have no doubt that it is possible to do so. However, learning XHTML properly requires that it be learned under XML conditions and, as I mentioned in the article, there is a significant amount of evidence to show that the vast majority of beginners learn under HTML conditions.

    Ideally, if the web worked fully under XML conditions (i.e. Internet Explorer, Google and every other browser supported XHTML), then yes, beginners could learn it correctly from the beginning, but under HTML conditions, it is so much harder to learn/teach XHTML correctly. (In fact, by teaching it under HTML conditions, it’s simply not being learned or taught correctly at all).

    To prove this fact, pick any web page claiming to be XHTML served as text/html that hasn’t been written by an extremely knowledgeable web standards advocate, and I can almost guarantee you’ll find a number of issues that will mean it simply won’t work under XML conditions.

  14. Roger, I’m going to respectfully disagree here. This reminds me of when I took a sewing class (yes, I actually took a sewing class with my wife once) and the instructor at one point in response to a question said:

    “I teach sewing the right way. If you want to cut corners or take shortcuts at home, fine. But here, I’m going to teach you the right way.”

    So she held her ground where sewing (standards?) are concerned. I think I would adopt the same attitude when teaching web design.

  15. I might be too experienced cough, but I find XHTML al lot simpler. 75 vs. 90 different elements and no doubt about what element does what and where.

    They didn’t teach me “ye olde english” first either. :)

  16. I must say that I am getting sick and tired of the argument that XHTML cannot be learned/taught/used if it isn’t delivered with the application/xhtml+xml MIME type. Web page code and delivery method are two different issues. If I emailed you valid XHTML 1.1 code, could you really complain that I sent you tag-soup because I hadn’t emailed you the code using the application/xhtml+xml MIME type? No, you couldn’t - the code stands valid.

    Many people learn (X)HTML either on an isolated computer (i.e., their desktop in front of them, not a Web server) or using a Web server configured by their school over which they have no control. If they develop valid XHTML (1.0 Transitional, 1.0 Strict, or 1.1) pages in these situations, are they creating tag soup (assuming valid code)? No.

    What if they upload their code to a free hosting service (so they can show their “stuff” to friends and family) and the free hosting service delivers all pages using text/html, do they have tag soup? Maybe but is it their fault? What about a purchased Web hosting service? How easy/hard is it to modify the server to deliver .html pages as application/xhtml+xml? Is it even possible? Must you purchase a dedicated hosting package to fulfill the requirements for application/xhtml+xml? Hopefully not. You could route XHTML pages through PHP and set the header using PHP but that would be a detriment to beginners to have to learn PHP (even just this little bit of code) as well as XHTML.

    For these reasons, I believe that the MIME type should not be an impediment to teaching/learning XHTML over HTML because the code stands separate from the delivery method.

  17. December 7, 2005 by Scott

    I’m also going to respectfully disagree with Roger and Lachlan. In my first year of post-secondary education, we were taught a language called Ada95. Very few people use it in the real world anymore, but it is very strongly-typed and they wanted us to learn how to write code properly. I think the same applies to the web. HTML4 suffers from being too lenient, hence why XHTML was created. I do not disagree that XHTML served as HTML is not ideal, though I’m not convinced that it’s harmful. Even when served as text/html, XHTML forces you to write better code. IMHO it’s better to teach someone strongly-typed XHTML than lenient HTML4. As others have said, it’s more difficult for someone to learn XHTML who has been doing HTML4 for so many years than for someone who has never done HTML4. Newcomers don’t have the years of bad habits to break.

    This whole thing about “well-formed” and “tag-soup” gives me a bad impression, as if most of the world is too stupid to write proper code. Not only has the XHTML vs. HTML argument been resurrected, but it seems the elitism argument is also being resurrected. From what I understand, XHTML enforces well-formedness whereas HTML4 does not. As for tag soup, seems to me that problem is independant of whether you choose HTML4 or XHTML. XHTML does not become tag soup just because it is served as text/html. That is like saying two cars of the same make and model are not equal if they are different colors.

    Some of the pitfalls of XHTML only apply when using Javascript. Most people just learning HTML or XHTML are not learning Javascript yet, and they can learn those things later. (Writing proper Javascript is another large issue in itself.) This is no different from how high school students are taught physics. Physics equations at the high school level assume no friction. By your argument, we should not be teaching physics in high school because leaving out friction is not correct and including it is too difficult for the students to understand. Similarly with chemistry, the teacher only tells students about protons, electrons, and neutrons. What about the other subatomic particles? What about their corresponding anti-particles? What about neutrinos? That’s too difficult for the high school level, so I guess we can’t teach chemistry anymore either. While we’re at it, we’ll stop teaching math because there’s plenty of difficult concepts there too.

  18. I find XHTML al lot simpler. 75 vs. 90 different elements

    HTML 4 and XHTML 1.0 have exactly the same number of elements, this is just another one of the many myths about XHTML. A Strict DOCTYPE has few elements than a Transitional DOCTYPE in both HTML 4 and XHTML 1.0. XHTML 1.1 actually has more elements than XHTML 1.0 Strict because Ruby is included as well.

  19. Jules, changeing the MIME type based on the file extension is trivial for anyone who’s host uses Apache (most do). Look up .htaccess files and the AddType directive. Also, it’s more common to use a .xhtml extension for XHTML pages, that way browsers will also use the right MIME type from the local file system.

    Create a file called .htaccess, add the following line to it and upload to your server.

    AddType .xhtml application/xhtml+xml

  20. Oops, I wrote that example backwards. It should be:

    AddType application/xhtml+xml .xhtml

  21. December 8, 2005 by Sverre

    Teach people how to write valid HTML Strict.

    Teach them how to make pages accessible for different people and UAs.

    When people understand how and why one should do this, then it´s time to start thinking a little bit about what XHTML is and how it´s supposed to be used.

    If you only write XHTML because you want valid code (and brag about it with at button on your page), there is no use at all! You can accomplish clean/valid/good semantic code with good ol´ HTML Strict!

    When serving XHTML as text/html to browsers that doesn´t handle XHTML-MIME-types, you´re biting yourself in the arse if the intention was to serve the browser with valid code. Why? Because those browsers doesn´t parse the document like XHTML, it parses it like it was HTML…and we all know that there are semantic differences here.

  22. December 8, 2005 by Tommy Olsson

    Judging from most of the replies to this post, your message didn’t get through, Roger. I’ve tried to say this many times, as you know, but I couldn’t make people understand either.

  23. Basically; be aware of the differences between them as they aren’t the same it only “mimics” the same appearance so use with caution.

  24. I wonder how many there are who actually test their “xhtml” designs as xhtml.

    Shouldn’t take long to add an ‘x’ to the ‘http://www.whatever.html’ extension - get ‘http://www.whatever.xhtml’ - and see what happens.

    Only two possible answers:
    1: it isn’t working in xml compliant browsers, so it is not xhtml.
    2: it is working perfectly in xml compliant browsers, so it probably is xhtml after all.

  25. I’ve seen experienced web developers who know HTML very well have problems getting XHTML right.

    And that’s the point. You’ve seen people who have accumulated bad habits during their years of using loose HTML. It doesn’t apply to people that started with XHTML, because they’re used to the restrictions from the beginning. Unlearning takes much more effort than learning.

  26. “the code stands separate from the delivery method” - Jules

    Great points Jules and Scott. It’s called progress. Better coding practices through improved standards…that’s why they’re there.

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.