|
To understand what xhtml is we first need to take a look at the last html specification this was html 4.01 which was combined with CSS (Cascading Style Sheets) to format the contents of html documents.
The source of the material I have used on this page is from the book
HTML, XHTML, CSS, Bible 3rd Edition Published by Wiley.
Authors: Bryan Pfaffenberger, Steven M Schafer, Chuck White, and Bill Karow.
Combined with CSS, HTML 4.01 was a major advance, so one might expect even better versions of HTML in the future, right?
Not according to the World Wide Web Consortium.
Apart from a minor update (HTML 4.01) in 1999, HTML 4.01 is the last version of HTML, thats because it has been replaced by XHTML.
Actually, there's very little difference between HTML and XHTML.
It's a matter of making a few changes to your HTML 4.01 code to make sure it's XHTML – conformant.
The main difference between HTML and XHTML is that every tag must be closed even those that do not have a closing tag such as the <hr> they must be closed in this manner <hr /> and they will be XHTML conformant.
Even the <br /> line break, and meta <meta /> tags like all tags must be closed in this manner.
But there is a much deeper reason for this change, to understand why HTML has become XHTML, you must learn a little about XML, another World Wide Web Consortium standard.
HTML is based on SGML, an international standard for markup languages, actually SGML isn't a markup language in itself, it's a language that's useful for creating markup languages.
You can use it to make up codes for just about anything you want.
For example an accounting firm could use SGML to markup the structure of accounting documents. One code could be used to mark daily totals, while a different code could be used to mark monthly totals.
To keep a record of all these newly created codes, as well as to specify them for presentation devices, a special file called a document type definition (DTD), is used. HTML 4.01 is defined in a document type definition, written in SGML.
SGML isn't equally loved by all.To many, SGML is outmoded, overly complex and too difficult to learn.
So the World Wide Web Consortium decided to create a new version of SGML that would be simpler and easier to learn.
The result is the Extensible Markup Language (XML).
Like SGML, XML enables people to define new markup langauges that are exactly suited to their purposes.
Source: HTML, XHTML, CSS, Bible 3rd Edition
To create HTML that is XHTML – compliant, HTML 4.01 elements and attributes must follow XML rules.
-
Empty elements must either have a closing tag or use the XML empty element syntax, shown in the example below:
<img src="/images/logo.png" alt="Our logo">
</img>
-
To support older browsers, the empty element syntax should include a space before the trailing slash, as shown in the example below:
<img src="/images/logo.png" alt="Our logo" />
-
Because XML is case – sensitive, all elements and attributes must be lowercase.
-
Attribute values must always be quoted.
-
Minimized attributes are not allowed. Attributes that do not take a value must be given a value equal to the name of the attribute, as shown in the examples below
-
<input checked="checked" />
-
<select multiple="multiple">
Source: HTML, XHTML, CSS, Bible 3rd Edition
Although XHTML may be a very rigid language there are many advantages to be gained from it's use.
Working with XHTML will help to keep your code a lot tidier and more consistent, and well structured
This will then make your documents a lot easier to edit and update later, especially if you have formatted the contents of the documents using CSS.
It also makes it a lot easier to convert or generate a data base from your documents and code, or adapt for other types of devices.
XHTML takes a logical step forwards in the transition from HTML to XML, by using the familiar elements and attributes of HTML and the syntax of XML.
The fact that XHTML is insistence on standards should ensure that it's consistently and properly supported by all the popular browser's on all platforms.
Web page accessibilty is required by law in the USA, and this is also the case with many other countries around the world too.
There are many web pages on the web that contain "bad" HTML and the document may render in a browser, but not all browsers even though it does not follow the rules.
Unfortunately todays market consists of many browser technologies for desktop PC's, mobile phones, PDA's, even fridges, but many do not have the power or the resources to interpret "bad" markup language.
So by adopting XHTML you can reach a wider audience and also future proof your documents and it certainly makes the code less cluttered and a lot easier to read the code later.
This in turn helps to make it a lot easier to update,edit and maintain the documents, and saves a lot of time and energy at the same time too.
|