Diverse

Diverse

How to create a XHTML document

XHTML is a cleaner,more strict version of HTML.
This tutorial assumes you already got basic HTML knowledge. If you don't, but want to learn, you can check out
W3schools HTML tutorial

Just like a HTML file, a XHTML file is saved with the extension .html.

OK,let's get started!

If you want to create a XHTML document that is multi-browser compatible, as long as the browser is able to display markup specifications correctly, you can validate the document using the world wide web consortium's HTML validator

In order to use the validator, some information has to be stated in the beginning of the document source code: The Document Type Definition (DTD), the XML namespace and the HTML character set.

The source code of a minimal XHTML document can look like this:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
</body>
</html>

The Document Type Definition (DTD)

The XHTML document type definition you want to use is stated in the very beginning of the XHTML document.
This is done by adding a URL pointing to a DTD file that resides on the world wide web consortium website.
The DTD choosen specifies which tags can be used in the source code.

There are three standard XHTML DTDs: Strict,Transitional and Frameset.

XHTML 1.0 strict

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Use this DTD if you don't want to use any of HTML's presentational features.

XHTML 1.0 Transitional

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Use this DTD if you want to use some of HTML's presentational features.

XHTML 1.0 Frameset

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Use this DTD if you want to use frames.

The XML namespace

The XML namespace URI enables the HTML validator to check for duplicate names or IDs' on elements in the
XHTML document. A method to avoid element name/ID conflicts.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

The HTML character set

HTML character set tag defines which character set webserver/browser is to use when serving/displaying the document.

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

References

HTML and XHTML

Document Type Definition (DTD)

HTML <!DOCTYPE> Declaration

XML namespace

XML namespaces
ISO 639-2 Language Code List - Library of Congress list of HTML/XML language codes

HTML character set

HTML meta http-equiv attribute

HTML ISO 8859-1 reference - A list of special characters and the entity number/name that is used in the HTML/XHTML code to display them
Another list of special characters in HTML - A list of special characters and the entity number/name that is used in the HTML/XHTML code to display them.

HTML charsets
IANA list of official HTML charsets