This article is for those who want to learn about the basic rules of XHTML or want to know what XHTML is and its syntax.
If you have a basic understanding of HTML you should have no problem adapting to the successor, the refined and updated XHTML.
XHTML has been developed in order to iron out some of the less savory elements of the older language, and is – in essence – a tightened up version of HTML that is expected to be utilized on the internet in place of the original for the future.
A Stricter Way of Programming
The major basic change between the two languages involves XHTML being more ‘strict’ in the definition of tags.
For example, take the following tag, an ‘empty’ element as it is known:
This is a simple tag naming an image, and acceptable in HTML programming.
Now look at how it must be written in XHTML –
<img src="xyz.jpg" />
The difference is very subtle, but very important: in the second example, the tag has been correctly closed, leading to no possible misinterpretation. This is a common theme throughout the newer language, which insists on correct closing of such tags in order to facilitate a cleaner and less error prone programming.
Lower Case Mandatory
In addition, whereas tags could be entered in lower or upper case in HTML, the use of lower case only is mandatory for XHTML.
Likewise, if you are using ‘paired’ commands in non empty elements, ones that refer to text that will appear on the screen, these must be correctly opened and closed. For instance, take the following example that is for bold text:
<b>This is the title</b>
We can see the differences in opening and closing empty, and non-empty, elements that must be adhered to.
In addition to the above basic rules, there are rules regarding the formatting of documents that must be adhered to in the use of XHTML. The basic premise of these is that the document must be formatted in a particular way, and must include a root element and the correct syntax able to be recognised by the newer language. To define all of these at this point would be to get ahead of ourselves, however.
XHTML also includes improved methods of defining tables and their structure, as well as a number of further improvements over the original, but the basic rules we need to remember at this point are those outlined above, and to be aware of the necessity of a stricter adherence to the rules of syntax and form.
The revisions to the language are required as the internet advances into the world of hand held devices and mobile phone access, and XHTML has allowed these methods to be refined in line with projected future requirements.