Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Part 2.5HTML vs XHTML

Part 2.5HTML vs XHTML

The differences

HTML and XHTML are very similar syntactically. There are some fundamental things that make both very different however.

The most important difference between the two versions of HTML is the strictness. Simply put, a standard web page written in HTML is not strict, whereas one written in the XHTML serialisation of HTML is strict. Here is a list of things that XHTML brings to HTML.

  • A DOCTYPE is an essential
  • <html>, <head>, <title> and <body> are required
  • All tags must be closed. This means things like breaks and images must be closed.
  • All elements and attributes must be lowercase
  • Elements must be properly nested
  • There must be exactly one root element
  • Attribute values must be quoted

Some people would say that XHTML is easier to learn than standard HTML, due to the strictness. This means that <h1>Page<p> cannot be included, for instance. In HTML this will run correctly, but takes longer to parse and therefore is not fully qualified HTML and not following the validation rules for well-formed HTML. One should be careful with such HTML, as it can display differently as per browser and platform. As such, HTML which does not follow the W3 recommended rules should be avoided.

This is where the strictness of XHTML comes in handy. The XHTML would have problems altogether and would not display a page which cannot render correctly. Some also say that HTML5 is more strict than previous versions, and there is no current XHTML5 specification that has been standardised.

Why bother?

The argument about why to bother with XHTML is becoming less and less important over time as HTML5 progresses and on its own becomes more strict.

As XHTML takes a long time to become a standard after a version of HTML is released, it tends to be ignored by early adopters of the latest HTML standards.

Feedback 👍
Comments are sent via email to me.