Home
• Attribute names must be in lower case
• Attribute values must be quoted
• The id attribute replaces the name attribute
• Attribute minimization is forbidden
• The XHTML DTD defines mandatory elements
• Attribute names must be in lower case
This is wrong: <table WIDTH="100%">
This is correct: <table width="100%">
• Attribute values must be quoted
This is wrong: <table width=100%>
This is correct: <table width="100%">
• The id attribute replaces the name attribute
HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe,
img, and map. In XHTML the name attribute is deprecated. Use id instead.
This is wrong:
<img src="picture.gif" name="picture1" alt="picture1" />
This is correct:
<img src="picture.gif" id="picture1" />
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">Hello</div>
• Attribute minimization is forbidden
This is wrong:
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>
This is correct:
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />
<frame noresize="noresize" />
• The XHTML DTD defines mandatory 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.
This is a minimum XHTML document template:
<!DOCTYPE Doctype goes here>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title goes here</title>
</head>
<body>
Body text goes here
</body>
</html>
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.
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.
The Strict DTD includes elements and attributes that have not been deprecated
or do not appear in framesets:
!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
The Transitional DTD includes everything in the strict DTD plus deprecated elements and attributes:
!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd<!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">The Frameset DTD includes everything in the transitional DTD plus frames as well:
!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"
• XHTML Syntax Rules
• XHTML Modularization
• XHTML Standard Attributes
