build-website-header
spacer-image
 

XHTML Explained

After learning about HTML you may well be wondering what is XHTML? and what has happened all of a sudden to HTML. Well first of all don't panic- HTML is alive and well.

So what is XHTML? and how is it different from HTML? and what you should you be doing about XHTML?

 XHTML stands for eXtendable Hypertext Markup Language and will eventually replace HTML.

 It is basically a more stricter form of HTML. By stricter I mean that the rules/syntax will be much more strongly enforced than with HTML.
With HTML many browsers would simply ignore HTML errors with XHTML they will produce an error.

Why XHTML?

XHTML is required because of the many news ways available of connecting to the Web- mobile devices, household devices etc. The growth of the type and number of these devices will continue to grow, and they will require a greater adherence to standards to ensure that they all work correctly.

Also XHTML can be extended like XML (Extensible Markup Language) which means that in the future specific devices may use their own custom extensions.

What is the Difference between HTML and XHTML ?

There is very little difference between the two. If you understand HTML then all you need to do to convert to using XHTML is to observe a few basic rules. There is no need to learn a new language.


The main characteristics of XHTML are:

  • Case-sensitive everything is written in lower case.
  • All attribute values must be in quotes.
  • Tags must be nested properly .
  • All tags must have closing tags or written in a special format that combines the opening and closing tag - <br/>

See HTML to XHTML in 10 steps for more details.

Do You Need to Start Creating my Web Pages in XHTML

As most people don't hand code HTML they wont be hand coding XHTML. Therefore, if your web page editor supports XHTML then just make sure that it is configured to use it and that is all you really need to do.

If your web page editor is only capable of producing HTML then I wouldn't worry about it at this time (Nov 2005)  as HTML will be supported for many years to come. I would however look around for a newer version or use the popular free versions like NVu. -See web Page editors.

Web Page Editors and XHTML

Most of the popular web page editors have support for XHTML. The level of compliance varies and depends on how you have configured it. If you are wanting to create strict XHTML web pages then you also need to use Cascading Style Sheets for the web page layout (see below).

Do I Need to Convert my Existing Web Pages in XHTML

Again HTML isn't dead and will continue to be supported. I personally wouldn't go to the trouble of converting existing content. The conversion process is however relatively straightforward provided your HTML code is already tidy.

If the HTML code is already Validated (see web page Validation ) then conversion is simply a matter of converting upper case tags to lower case using a global find and replace and other simple reformatting procedures.

You may wish to have a look at a website conversion example  to see what elements you need to convert.

Unfortunately most web pages aren't 100% correct and hence the code needs first to be correct HTML . In this case you would be better using the free HTML tidy utility or the graphical  HTMLTrim or TidyUI to do the conversion. These tools will correct invalid HTML and convert HTML to XHTML.

 Don't forget that the first page you should convert and validate is your website template page.

When using conversion tools always thoroughly test them on a few sample files before you start on your real web pages and always ensure that you have a backup of those pages before you start.

Web Page Layout and XHTML

In XHTML you need to completely separate the page content form the page formatting. In order to do this you  should use CSS for you website layout.

However, even today the use of tables for web page layout is very common, and although it doesn't satisfy the XHTML/CSS purists it is still the easiest way to layout your web pages.

What I do, and what I would recommend, is that you continue to use a table for the main layout but use Cascading Style Sheets to format the table and page content.

Summary

Web standards are constantly evolving and just like HTML had many versions so will XHTML. Standards as someone said are fun as there are so many of them.

From the perspective of a web content publisher I wouldn't worry too much over the latest standard issues. Instead just configure your web page editor to create the level of XHTML you desire and let the developers of those editors worry about the standards.

 Related Articles and Resources:

 

 

 

 

 


Add to My Yahoo!



Free Newsletter!