I work hard, so you don't have to

What is XHTML?


You may have heard lots recently about this new(ish) buzz word XHTML. You may be wondering what is it? How does it affect me? Why not use HTML...

Xhtml stands for eXtensible Hyper Text Markup Language. It is the new format introduced by Tim Burners Lee and his team of web musketeers at the world wide web consortium.

As i'm sure you are aware XHTML, is a markup language, which in plain english is a way of laying out your site to a visual effect. The old format was HTML and I will need to write a whole article on why XHTML took over from HTML. When thats done i will make this a link.

When a builder makes a house he has certain standards that niether love nor money will make him break. In the same way builders have these standards that they must legally uphold, websites too have rules and standards to obey.

Xhtml is our standard, and the W3C is our geverning body.

There are a few basic rules when it comes to using XHTML, i have never been taught these directly, however i'm pretty sure i can name the main ones :)

  • A Valid DocType must be used. - In order for your site to be valid XHTML your markup needs to tell the browser which standard you are using to display the content. Some tags which are depricated in one version are perfectly valid in another specification.
    The below doctype is for xhtml1.0 strict.
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "" >

    The doctype needs to be the first line of markup in your document.
  • DO NOT use depreicated tags - Since html many tags have been depricated the reasons for these are quite interesting. So interesting My next article will be about that reason. But for now just understand that some tags have been depricated. Two common tags that have been depricated are the font and marquee tags.
  • Always close the tag - You may remember from HTML, that when you open a tag, if you want to finish that formatting you will need to close the tag. However there were some tags that didn't appear to need the be closed. An example of this type of tag is the line break (br) tag. HTML allowed the use of < br >, but in XHTML you need to self close... < br/ >. This is the first step to ensure the next rule.
  • Use proper nesting - When writing a complex set of styles, you must ensure your tags are properly nested. take the following sentance...
    I am the CodersAdvocate.
    How would you do that?
    Theres the wrong way.... < strong >I am < em >the < /strong >CodersAdvocate.< /em > And theres the correct way.... < strong >I am < em >the < /em >< /strong >< em >CodersAdvocate.< /em >

If you follow these simple rules your page will surely be xhtml valid. And you will be able to make your own pages :)

Happy Coding...

Copyright 2011 CodersAdvocate ©