How To Compare HTML and XHTML

In the beginning, web designers built Web sites with HTML or Hypertext Markup Language. Today with the combination of XML or Extensible Markup Language, and XHTML or Extensible Hypertext Markup Language was created to provide stricter codes that will be the standard coding language used by all browsers and applications. If you've been using HTML for a while you will notice the differences but it won't be too difficult to shift to XHTML.

  1. The DOCTYPE definition and XMLNS attribute - One of the first differences you'll notice on an XHTML document is the DTD or Document Type Definition or simply DOCTYPE definition that is seen as the very first tag. It is always written in the beginning of the document which tells the browser what sort of building blocks are used in the document in order for it to be read properly. This is an example of how the DOCTYPE definition is to be written at the beginning of your XHTML document:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

    Note that the DOCTYPE definition must be written properly or else the document will fail to initialize. Another important tag at the beginning of the document is the XMLNS attribute found under the DOCTYPE definition. It is required in all XHTML documents and will look like this:

    <html xmlns="">

    Do not forget to write this tag at the beginning before doing any coding.

  2. Proper order of tags - The tags in an XHTML document must be ordered correctly, unlike in HTML where you can get away with poorly ordered tags. This is an example of how the basic tags should be ordered in your XHTML document:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="">



    The HEAD tag is found at the top containing the TITLE tag which gives your document a name or title and will be displayed on the browser's title bar. The BODY tag follows after the HEAD tag; the content for the Web site will be contained in this tag. Other formatting tags contained within the BODY tag should also follow the proper order for the document to display its content the right way. Take for example the <p></p> paragraph tag where you start typing in your content, the closing tag </p> should not be written outside of the </body> tag. When you use other tags to format content within the <p></p> tag, they too have to follow the tag ordering style.

  3. Case sensitivity and closing tags - In HTML you can use either capital letters or lowercase letters or both at the same time in tags but in XHTML all elements and attributes must be written in lower case to keep tags consistent. All tags that are used in the XHTML document must be closed with the proper closing tags or else the document will not function correctly.

These are just a few differences between HTML and XHTML, but these are some of the most important details that you need to remember when coding in XHTML.


Share this article!

Follow us!

Find more helpful articles: