If you are a professional Web designer and create HTML/CSS code by hand for living, then you might be interested in the fact that Dave Shea switched from XHTML 1.0 to HTML 4.01.

It’s a fact that:

1) Lately, the HTML 5 standard gains up in speed.

2) XHTML 2.0 probably will never become a successor to XHTML 1.0. In fact, XHTML 2.0 probably will never exist at all.

3) Quite a few prominent Web designers and CSS/HTML coders are abandoning XHTML 1.0 and go back to HTML 4.01 (some of them even experiment very seriously with HTML 5).

What HTML standard for documents do you prefer? And am I the only one who (still) prefers XHTML 1.0 over HTML 4.01? :-)

It followed the interesting discussion at mezzoblue — I managed to read almost all of the comments there!

But, sometimes, it is not very clear to me as to where & why are going the Web Standards, guided by W3C.

After HTML 3.2, HTML 4.01 came, then the XHTML 1.0 standard was adopted, and now HTML 5 is developed? There’s almost no logic behind the versioning; plus, we have first the HTML language (which, in turn, derived from SGML), then W3C decided that it would be a great idea to combine XML + HTML (and so, XHTML 1.0 was ‘born’), and finally, they turn back to the idea of ‘pure’ HTML, and in the new standard (HTML 5), the ‘X’ is missing…

What’s up next? I don’t know.

Personally, I am a bit puzzled by the fact that the first standards, which I’ve learned, when I started doing Web design, were HTML 3.2 and HTML 4.01, then came XHTML 1.0 (“The Next Best Thing Since Sliced Bread”, after HTML 4.01) — at this time I had to learn how to close tags, which you don’t have to close at all (such as img and br, for example)… And now, after XHTML 1.0, it’s HTML’s turn again?

For now, I don’t plan to change my coding style. XHTML 1.0 Transitional & Strict are doing a great job.

Besides, using HTML 4.01 has certain drawbacks (compared to XHTML 1.0):

For example, under HTML 4.01, the closing of some tags is not obligatory at all — <p>, <li> can be opened, but you don’t have to close them after that, so the following two examples are both valid:

example 1:

<ul>
  <li><a href="#">Lorem</a></li>
  <li><a href="#">Ipsum</a></li>
  <li><a href="#">Dolor Sit</a></li>
</ul>

<p>Lorem ipsum...</p>

<p>Lorem ipsum!</p>

example 2:

<ul>
  <li><a href="#">Lorem</a>
  <li><a href="#">Ipsum</a>
  <li><a href="#">Dolor Sit</a>
</ul>

<p>Lorem ipsum...

<p>Lorem ipsum!

This could lead to the situation, when the following example will be perfectly valid for the W3C validator:

example 3:

<ul>
  <li><a href="#">Lorem</a>
  <li><a href="#">Ipsum</a></li>
  <li><a href="#">Dolor Sit</a></li>
</ul>

<p>Lorem ipsum...

<p>Lorem ipsum!</p>

…but it will not look very well as code.

Under XHTML 1.0, there is no such problem. Only example 1 will be valid, when all opened tags are correctly closed. Such code is easier to be checked for any accidental mistakes, and it can be also read much easier by a machine.

Also, you don’t have to use quotes for HTML attributes under HTML 4.01.

example 4:

<div class=container>
  <p>Lorem Ipsum...</p>
  <p class="blue">Dolor sit...</p>
</div>

Code like this will be valid for HTML 4.01, but not for XHTML 1.0. Under XHTML 1.0 only the following example will validate (when attributes are quoted):

example 5:

<div class="container">
  <p>Lorem Ipsum...</p>
  <p class="blue">Dolor sit...</p>
</div>

There are some more differences with HTML 4.01. Special characters like ‘&‘, " (quotes), etc., are not necessarily encoded (under XHTML 1.0, the ampersand sign (&) should be encoded as &amp;, for example).

Let’s not forget also that most of today’s CMS systems are programmed with XHTML 1.0 in mind (and not HTML 4.01), and if you use HTML in such a situation, it’s possible that you’ll end up with some ‘code mix’ — HTML & XHTML together in one page; in such a case, you’ll have to modify the way in which the particular CMS is working, or the code won’t validate at all…

* * *

If you are a good designer, you won’t have any problems using both HTML 4.01 and XHTML 1.0, without any noticeable difference. But even if you have a lot of experience in this area, using HTML 4 might hide certain caveats — it is much easier to allow certain types of mistakes, which the validator won’t find at all (such as opened, but not correctly closed tags, etc.). From there to ending up with some kind of a tag soup, is just one small tiny step… On the other hand, XHTML 1.0 is much more strict in this aspect, and will learn you easier how to write well-formed (and well formatted) code.

I am observing with much interest the development of HTML and CSS, but for now I did not hear any strong arguments so that XHTML 1.0 to be abandoned (in favour of HTML 4.01, for example). As to HTML 5, for now it is only a working draft, and it has a long road to go, before it becomes a mature and well-supported standard…

I prefer to use some new features, present in CSS3, which modern browers already support (like CSS rounded corners — Firefox and Safari have perfect support for them), than trying to start coding again in HTML style, without the ‘X’:-)

I might be wrong, but I prefer the stricter way of coding, which XHTML 1.0 imposes… Just a simple habit?

May be! :-)

9 thoughts on “XHTML 1.0 vs. HTML 4.01 (or HTML 5)?

  1. its a bit late to comment on that now that (x~)html 5 is in favour, but i totally agree, xhtml code is nicer (and at least for me) easier to write. well, lets hope that html 5 will at least come soon, be good and unleash css 3 full support for the rest of the web! (IE?! ^-^)

  2. @taotsu-pro:

    My only concern is valid, nicely formatted code. HTML is a bit loose for me, as a standard — that’s why I prefer XHTML, which forces me to close all open tags, to have all attributes in quotes, etc. I hope that XHTML 5 will be an option for us, and that we could still serve it as text/html (because of IE7 and below, of course)! :-)

  3. You forget that HTML 5 uses XML too (it defines both HTML-based and XML-based version, you choose which one you want).

  4. @kl:

    My knowledge of HTML 5 is still incomplete… :)

    So I was taking a closer look only at HTML, and in HTML, you can leave some tags open and you can use quotes for attributes (or not, that’s your choice) — basically, HTML will allow you to write less strict code than XHTML.

    And I am not yet sure that XHTML 1 will have its equivalent as XHTML 5 (at least, the ‘standard’ variant that we are used to, when you serve code as text/html, because of older versions of IE…). This worries me a little bit, as I prefer all tags closed and everything strict and semantic in my HTML…

  5. On the one hand i have to agree that XHTML is cleaner and better formatted, on the other hand afaik HTML5 is a consolidation of XHTML1 and HTML4 so you can go either the one way with open tags or the other way. Yet i personally stick to XHTML1 (transitional) since the code structure looks more logic to me and i can find invalid code much faster. Also in my opinion HTML 4 sometimes can be a pain in the ass if you do not use a wysiwyg editor (i prefer notepad++ over wysiwyg tbh).

  6. @Dan:

    Yes, I prefer XHTML 1.0 too. Easier to validate, all open tags should be closed, code looks better and more logical. :)

Leave a Reply

Your email address will not be published. Required fields are marked *