XHTML – What It Is, Why You Should Use It and How it Differs From HTML

XHTML – What It Is, Why You Should Use It and How it Differs From HTML

Another web page language is XHTML. The acronym stands for eXtensible Hyper Text Markup Language. In context, XHTML looks like standard HTML. The difference is that this language has more rules that MUST be followed to achieve the desired outcome. In that sense, XHTML is more exacting and a bit cleaner.

A worthy note here is that the two languages, HTML and XHTML, can work side by side in the same document. That is to say that you can write a web page using both languages and it will work just fine. This is because XHTML is a combination of HTML and a les lenient markup language called XML. XML is designed as a descriptive element to data while HTML is designed as a display element. Therefore, the two are compatible.

The reason we want to use a clean language on our web pages is cross browser applications. Technology has given us many different types of browsers. Some of these run on our laptops and home PCs. Others run inside mobile devices like phones, blackberries and PDAs. These browsers are not able to read and effectively display bad or broken HTML. So the exacting syntax of XML makes XHTML compatible across all these browsers.

There are four main differences between the two languages. First, elements in an XHTML document need to have proper nesting syntax.

This means that you need to close the LAST tag first in nested tags, like this:

<i><u>This text is underlined and italicized</u></i>

Notice how I closed the “underline” tag first even though it was opened last.

Next, all elements in an XHTML document MUST be closed. Each and every opening tag you write HAS to have a closing tag. This is not the case with standard HTML.

Third, all XHTML tags or elements are ALWAYS written in lower case. No exceptions. No upper case letters in any tags.

Last, you must have one root element. This is usually the <html> tag you put at the top of the document. Everything else must be nested between that opening root tag and the closing </html> tag at the end of the document.

Several more rules apply here as well, as follows:

All tags or commands in lower case.

All values called or designated in the tags must be enclosed in quotation marks.

Making tags smaller, or minimizing them, is not acceptable.

There are mandatory elements that MUST be present in the document, ie…a doctype declaration and tags for html, body and title. These MUST be include in the document.

You can get started on switching your HTML pages to XHTML very easily. Start looking for open tags with no closings. Then look for capital letters in the attributes (tags) and make them lower case. Finally, be certain that you have a doctype declared BEFORE the HTML tag.

Do this and you’re on your way to writing your pages in one of the most widely accepted markup languages on the planet. Your pages will be visible to all users regardless of the device they are using. This gives you a larger audience and the possibility for more visits and success.