basics of website design banner photo

HTML

HTML 5

CSS 2.1

CSS 3

Reference





What is XHTML

XHTML stands for Extensible Hypertext Markup language and is HTML rewritten so that it complies with XML syntax rules. This theoretically means that pages written in XHTML are easier to extend(add features to) and more usable in differing programming languages and situations than HTML.

In addition to this as the syntax rules are stricter they encourage you to develop good coding practices which will stand you in good stead when you move onto other programming languages most of which have very strict syntax rules.

HTML to XHTML - changes.

The differences between HTML and XHTML stem from that fact that they are derived from two separate languages, HTML from SGML and XHTML from XML.
In XHTML documents must be well-formed, a principle which dictates the following rules:

Names must be in lowercase

In HTML there is no distinction between <html> and <HTML> , but in XHTML all tag and attribute names must be in lowercase as XML sees <html> and <HTML> as two different tags.

Elements must be properly nested

To be nested correctly the closing tags of any open elements must be written in the reverse order of when they were opened. For example if you are styling bold text inside a paragraph contained within a div you will have opened <div><p> and <b> elements.
To be correctly nested the elements must be closed in this order </b> </p> and finally </div> as it was the first element opened.

Example of wrongly nested elements:

<b>Bold text<p><div></b>Normal text</div></p>

Example of correctly nested elements:

<div><p><b>Bold text</b>Normal text</p></div>

Always close elements

In HTML it is permitted to leave out the closing tags of some elements as the opening of another element implied the closure of the first. In XHTML all non-empty elements must have a closing tag and all empty elements must be properly closed.

When writing empty elements using the XHTML syntax you need to add a space and forward slash / following the element name giving you <hr /> and <br /> for example.

Root element must be <html>.

All the other elements within an XHTML document must be contained within the <html> element, to put it another way the opening <html> tag is placed directly after the Doctype Definition before anything else is opened and the closing tag <html/> is the last closing tag on the page as all the other elements must be nested between these tags.

The future of XHTML1

Back in 1998 the W3C made the decision to stop developping the SGML based HTML language and to focus it's efforts on the XML based language XHTML and published XHTML1.0. It was seen as a major step forward which would lead to a uniform web written with a strict syntax.

A major problem was that XHTML is very strict when it comes to error handling and error reporting and any errors in websites written in the far more forgiving HTML would cause them to simply stop working and display error messages to the user when served as XHTML - a disaster for the web. This wasn't something that could be allowed to happen so the W3C provided a get out clause to allow authors to construct pages using the XHTML syntax but to have them processed as if they were HTML using the MIME type 'text/html' instead of 'application/xhtml+xml', the correct XHTML content type.

This was seen as a way to ease the transition from HTML to XHTML and in May 2001 XHTML1.1 was released which no longer contained the get out clause and required XHTML pages to be served as XHTML with the 'application/xhtml+xml' MIME type.

But web designers had no need to change to the far stricter XHTML involving considerable effort and time and therefore cost when they could keep using XHTML1.0 which was backwards compatible with HTML sites. XHTML1.1 just wasn't taken up by the web design community in significant numbers which put it at odds with what was happening in the real world of the Web. As a result of this companies which made the browsers led by Opera and Mozilla and soon after Apple set up the WHATWG to further develop HTML and make it totally backwards compatible with previous versions of HTML and capable of gracefully handling any coding errors thrown at it.

The writing was on the wall for XHTML - the WHATWG was making good progress and the W3C was taking years to finish XHTML2 - and in October 2006 Tim Berners Lee announced that the W3C would work together with the WHATWG to evolve HTML.

Finally in July 2009 the W3C announced it was going to shut down the XHTML working group and focus on developpment of HTML5. Even though XHTML1.0 is used on millions of websites today there will be no further versions or updates and HTML5 is now the way forward. It is useful for web designers to understand XHTML as it is still so prevalent, but HTML5 is the future.

References

1. This is a very brief version of events between 1998 and 2009 which have led to the demise of XHTML. For a more thorough examination of this process please read Mark Pilgrim's excellent article at Dive Into HTML5.