Syncrat - An article website that focuses on Music, Dating & Relationships and Business & Money. Learn about music, improve your dating or learn to make your money go further.

Difference between HTML and XHTML

One of the reasons that today's browsers are so large is that HTML documents can be constructed much more loosely than XML documents. For example, the following is a perfectly acceptable HTML document:

<html>
<head><title>Message of the Day</title></head>
<body>
There is no message of the day.
<p>
Try back tomorrow.
</BODY>
</HTML>

But because the <p> tag isn't closed and the <html> and <body> tags don't match their closing tags, this isn't a well-formed XML document.

XHTML takes HTML as defined in version 4.01 and applies the rules of well-formed XML documents. In order to be an XHTML document, our example above would have to read as follows:

<html>
<head><title>Message of the Day</title></head>
<body>
<p>There is no message of the day.</p>
<p>Try back tomorrow.</p>
</body>
</html>

Flavours

XHTML is also broken down into several "flavours":

XHTML 1.0 Transitional
XHTML 1.0 Transitional contains all of the elements and attributes defined in HTML 4.01, with the notable exception of those related to the use of frames.
XHTML 1.0 Strict
XHTML 1.0 Strict contains only those elements and attributes related to structure, and very few of those related to presentation. For example, the <center></center> element is not part of XHTML 1.0 Strict.
XHTML 1.0 Frameset
XHTML 1.0 Frameset includes all of the HTML 4.01 elements and attributes, including those related to frames.

Other changes

With XHTML replacing HTML, there are a few more changes that are coming through, other than enforcing well-formed XHTML:

  • The tags must be lower case, so instead of <IMG SRC="resource/frankisboat.gif" WIDTH="389" HEIGHT="227" BORDER="0" ALT="boat">, as we would do in HTML, we instead use: <img src="resource/frankisboat.gif" width="389" height="227" border="0" alt="boat" />
  • All tags must close, either by using a corresponding closing tag which has a slash, like paragraph ( <p></p> ) for example, or some tags are self closing like the above img src tag and line break ( <br /> ). In HTML, many of these tags were simply left open.
  • All tags must be properly nested, so if you start tag "a" and then start tag "b", you must close tag "b" before you close tag "a".
  • Some tags which were previously allowed are no longer allowed.
  • All attributes must also be lower-case.
  • All values for attributes must be encased in single or double quotes.

Tags: , , ,

Related Items:

Comments / Replies

Add Comment / Reply

The address of your website or social networking page. Make sure that you include http://
You can not use HTML in this field. If you wish to add a URL, write the full URL including http://
 

This website follows the ideas of the No Nofollow, I Follow, DoFollow, No-NoFollow movement. Leave a helpful comment and you will get a link without NoFollow (U Comment, I Follow).

Web Hosting

If you are looking for web hosting then I would recommend my current web host. They have been good to me, suiting both beginners and advanced users.

Advertising

Using a transparent and trusted advertising network always helps to generate more revenue on a website. One of the networks I use achieves this more than the others.

Donations

If you would like to help pay the web hosting bill for this site, you can donate through my host

Your Ad Here

Web Hosting

If you are looking for web hosting then I would recommend my current web host. They have been good to me, suiting both beginners and advanced users.

Advertising

Using a transparent and trusted advertising network always helps to generate more revenue on a website. One of the networks I use achieves this more than the others.

Donations

If you would like to help pay the web hosting bill for this site, you can donate through my host