XHTML - What is XHTML and how to use it. XHTML
What is XHTML and How to Use it



May 1st, 2009:

XHTML - What is XHTML and How To Use it

XHTML stands for Extensible Hyper Text Markup Language. XHTML is an extension to HTML, or as W3C (World Wide Web Consortium) defines it, the latest version of HTML, which enables websites to be viewed on XHTML browsers as they appear in cell phones and hand-held devices. All new web browsers support XHTML.

This tutorial will show you how to modify your Web site's HTML code to comply with XHTML standards.

XHTML is a combination of HTML and XML, or HTML defined as an XML application. XHTML is very similar to HTML 4.01 and will gradually replace HTML.

XHTML Syntax

HTML displays data, and XML describes data. XHTML is a stricter version of HTML 4.01, which ensures websites to be compatible with regular web browsers as well as web browsers in mobile devices. All XML enabled devices have the ability to read XHTML. Another advantage of XHTML is that it is compatible with all (newer) web browsers. XHTML requires a "cleaner" code, which basically will make your website look the same in all major web browsers and thus eliminating design or layout differences across various web browsers.

The DOCTYPE Element

There are currently 3 XHTML document types:
  • STRICT
  • TRANSITIONAL (this is the most commonly used)
  • FRAMESET
XHTML 1.0 specifies three XML document types that correspond to three DTDs (Document Type Definition):
Strict, Transitional, and Frameset.

XHTML 1.0 Strict

<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.

XHTML 1.0 Transitional

<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Use this when you need to take advantage of HTML's presentational features and when you want to support browsers that don't understand Cascading Style Sheets.

XHTML 1.0 Frameset

<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Use this when you want to use HTML Frames to partition the browser window into two or more frames.

The 3 Document Type Definitions

DTD specifies the syntax of a web page in SGML (Standard Generalized Markup Language).
DTD is used by SGML applications, such as HTML, to specify rules that apply to the markup of documents of a particular type, including a set of element and entity declarations.
XHTML is specified in an SGML document type definition or 'DTD'.

An XHTML DTD describes the computer readable language and the allowed syntax and grammar of XHTML markup.

  • The DOCTYPE declaration should always be the first line in an XHTML document.
  • All XHTML documents must have a DOCTYPE declaration.
  • The HTML, head and body elements must be present, and the title must be present inside the head element.
  • The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.

More XHTML Rules

Make sure you write your XHTML code all in lowercase letters and don't forget to close ending tags

Make sure your XHTML elements are nested properly

Empty elements must be closed as well
For example: <br> = <br /> or <hr> = <hr />

To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol. Images must also be closed: <img src="sample.gif" alt="sample" />

Attributes must be in lower case as well. Attribute values must be in quotes.

More XHTML info to come...

© This Article is Copyrighted by WebmasterSeminar.com

Please do not copy or reproduce this article in whole or part, in any form, without mentioning the source and including a live link back to WebmasterSeminar.com - Thank You!

LINK TO THIS TUTORIAL:


Copy the code below and paste into your web page
<a href="http://www.webmasterseminar.com/xhtml.php">
Webmaster Seminar</a><br />
XHTML validation, information, Tips & Tricks

XHTML Related Links: