XHTML Introduction

XHTML is a stricter and cleaner version of HTML.

XHTML is a combination of HTML and XML (EXtensible Markup Language).
XHTML consists of all the elements in HTML 4.01 combined with the syntax of XML.

 The Most Important Differences:

Source code of this document contains examples that are w/in Comments

 XHTML Syntax

 Some More XHTML Syntax Rules:

Source code of this document contains examples that are w/in Comments

Here is a list of the minimized attributes in HTML and how they should be written in XHTML:

HTML            XHTML 
compact 	compact="compact"
checked 	checked="checked"
declare 	declare="declare"
readonly 	readonly="readonly"
disabled 	disabled="disabled"
selected 	selected="selected"
defer 	        defer="defer"
ismap 	        ismap="ismap"
nohref 	        nohref="nohref"
noshade 	noshade="noshade"
nowrap 	        nowrap="nowrap"
multiple 	multiple="multiple"
noresize 	noresize="noresize"

The id Attribute Replaces The name Attribute. XHTML has deprecated the name attribute
Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:
<img src="picture.gif" id="picture1" name="picture1" />

The Lang Attribute

The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.If you use the lang attribute in an element, you must add the xml:lang attribute, like this:
<div lang="no" xml:lang="no">Heia Norge!</div>

Mandatory XHTML Elements

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. Example used in dreameweaver:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">

Note: 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.

Note: The xmlns attribute inside the <html> tag is required in XHTML. However, the validator on w3.org does not complain when this attribute is missing in an XHTML document. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value and will be added to the <html> tag even if you do not include it.

XHTML Document Type Definition (DTD)

The XHTML standard defines 3 Document Type Definitions.
The most common is the XHTML Transitional.

An XHTML doc consists of 3 main parts:
  1. the DOCTYPE - this declaration should always be in the first line of doc
  2. the Head
  3. the Body

The DOCTYPE declaration defines the document type:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

The 3 Document Type Definitions There are currently 3 XHTML document types:

XHTML 1.0 specifies three XML document types that correspond to three DTDs: Strict, Transitional, and Frameset.

XHTML 1.0 Strict

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.

XHTML 1.0 Strict>XHTML 1.0 Transitional

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

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 Strict>XHTML 1.0 Frameset

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

Use this when you want to use HTML Frames to partition the browser window into two or more frames.

Converting from HTML to XHTML

XHTML Validation

An XHTML document is validated against a Document Type Definition.

Validate XHTML With A DTD

An XHTML document is validated against a Document Type Definition (DTD). Before an XHTML file can be properly validated, a correct DTD must be added as the first line of the file.

XHTML Modularization

The XHTML modularization-model defines the modules of XHTML.

Why XHTML Modularization?

XHTML is a simple, but large language. XHTML contains most of the functionality a web developer will need.

For some purposes XHTML is too large and complex, and for other purposes it's too simple.

By splitting XHTML into modules, the W3C (World Wide web Consortium) has created small and well-defined sets of XHTML elements that can be used separately for small devices, or combined with other XML standards into larger and more complex applications.

With modular XHTML, designers can:

XHTML Modules

W3C has split the definition of XHTML into 28 modules:

Module name Description
Applet Module Defines the deprecated* applet element
Base Module Defines the base element
Basic Forms Module Defines the basic forms elements
Basic Tables Module Defines the basic table elements
Bi-directional Text Module Defines the bdo element
Client Image Map Module Defines browser side image map elements
Edit Module Defines the editing elements del and ins
Forms Module Defines all elements used in forms
Frames Module Defines the frameset elements
Hypertext Module Defines the a element
Iframe Module Defines the iframe element
Image Module Defines the img element
Intrinsic Events Module Defines event attributes like onblur and onchange
Legacy Module Defines deprecated* elements and attributes
Link Module Defines the link element
List Module Defines the list elements ol, li, ul, dd, dt, and dl
Metainformation Module Defines the meta element
Name Identification Module Defines the deprecated* name attribute
Object Module Defines the object and param elements
Presentation Module Defines presentation elements like b and i
Scripting Module Defines the script and noscript elements
Server Image Map Module Defines server side image map elements
Structure Module Defines the elements html, head, title and body
Style Attribute Module Defines the style attribute
Style Sheet Module Defines the style element
Tables Module Defines the elements used in tables
Target Module Defines the target attribute
Text Module Defines text container elements like p and h1

* Deprecated elements should not be used in XHTML.

XHTML Standard Attributes

It is the same with HTML Attributes. Click THIS LINK to go to HTML Attributes

XHTML Event Attributes

It is the same with HTML Events. Click THIS LINK to go to HTML Events