XHTML: What you need to know

Introduction There are many pages on the internet that contain HTML that is either improperly formatted or just bad. These pages will render OK in most browsers. However, in certain situations they stand the chance of rendering incorrectly. Compound this with the limited rendering power of mobile and other hand-held devices and you stand a good chance of presenting a broken page to a large audience. To stop things like this from happening you can implement a good coding standard along with a strong code foundation that follows strict rules. What is XHTML? XHTML stands for eXtensible Hypertext Markup Language. Put simply, XHTML is HTML that implements the syntax rules of XML. XHTML is stricter, cleaner, and, in my own opinion, much more sensible than normal HTML. What's more, XHTML is not difficult to get used to at all. Once you start applying the rules in your code you will notice just how simple it is to present good markup. Lets take a look at the implications. The Groundwork XHTML is built on a very solid foundation that requires certain strict rules to be permanently enforced. These rules are:

  • Every page must have a Document Type Definition.
  • Every page must have exactly one root element.
  • All elements must always be typed out in lower case.
  • All elements must be properly nested.
  • All elements must be closed.
  • Attributes may not be minimized.
  • The id attribute replaces the name attribute.

Let us now look at these in more detail.

Every page must have a Document Type Definition.

There are generally three different dtd's that you can use on your web pages:

  • Strict: Use this DOCTYPE for clean, clear markup and use it with CSS
  • Transitional: Use this DOCTYPE when you are still going to use some of HTML's presentational features along with CSS
  • Frameset: Use this DOCTYPE when you intend to use frames on your site

SOURCE: http://www.wdvl.com/Authoring/HTML/XHTML/plotzxhtml.html

No comments: