html tag
body tag
head tag
title tag
DTD TAG: DOCTYPE
<!DOCTYPE ... >
The
DOCTYPE
tag is used to declare the DTD (Document Type Definition) for an XHTML document.
On a broader scale, XHTML, like HTML, is a subset of the SGML (Standardized Generalized Markup Language). SGML, and its various family members, use DTDs to define the context of the language. The W3C has defined a DTD to be:
"...a collection of declarations that, as a collection, defines the legal
structure, elements, and attributes that are available for use in a
document that complies to the DTD."
Specifically, the XHTML DTD precisely defines the grammar, rules, and syntax that will apply to a document that has been created using XHTML. To repeat this in a different way, to be valid XHTML, the XHTML code that creates the XHTML document must obey all of the grammar, rules, and syntax in the XHTML DTD.
This tag is mandatory and must appear at the top (on the first line) of all XHTML code. If the
DOCTYPE
DTD tag is not present, then it is not XHTML code.
The exclamation mark (!) is required. This is the only tag in an XHTML document that is not closed. Obey the case and syntax.
Currently, there are three types of DTDs that apply to XHTML:
Frameset, Strict,
and
Transitional
. You must obey the syntax.
Frameset
This is declared when you have partitioned the HTML document into two or more frames (with or without using Cascading Style Sheets).
Syntax:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "DTD/xhtml-frameset.dtd">
Strict
This is declared when you use Cascading Style Sheets (CSS) to enhance the appearance and style of your HTML document. In general, you should only use this type of DTD if you are certain that your viewer has access to modern browsers that recognize CSS.
Syntax:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml-strict.dtd">
Transitional
This is declared when you are simply using HTML to create the appearance of the web page, rather than using Cascading Style Sheets (CSS). This type of DTD would ensure the widest viewing audience to your XHTML document.
Syntax:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
The basic XHTML document is composed of
DOCTYPE, html, head, title,
and
body
tags. Note that all tags in XHTML are closed except for the
DOCTYPE
.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/EN" "DTD/xhtml-transitional.dtd">
<html>
<head>
<title>DevGuru</title>
</head>
<body>
DevGuru is great!
<br />
<img src="images/xhtmlvalid.gif" />
</body>
</html>
Output:
DevGuru is great!
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information