InformationWeek: The Business Value of Technology

InformationWeek: The Business Value of Technology
InformationWeek - Our New iPad App
News

May 8, 2000

Printer ready
Printer ready

Tags And Attributes In XHTML

Requirements
A strictly conforming XHTML 1.0 document is restricted to tags and attributes from the XHTML 1.0 namespace. Such a document must meet some exacting requirements: It must validate against one of the three document type definitions (DTDs); and the root element of the document must be <html> and designate an XHTML 1.0 namespace using the xmlns attribute. There must be a DOCTYPE declaration in the document prior to the root element and, if present, the public identifier in the DOCTYPE declaration must reference one of the three required DTDs.

Minimal XHTML
The following code, taken from the XHMTL proposed recommendation, is an example of a minimal XHTML 1.0 document:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
 		 xml:lang="en" lang="en">
<head>
<title>Virtual Library</title>
</head>
<body>
	<p>Moved to <a href="http://vlib.org/">vlib.org</a>.</p>
</body>
</html>

Some specifics
XHTML documents must be well formed, strictly complying with syntax rules. Tags must be nested properly and all tags must either have closing tags, or be written in a form that combines the opening and closing tag.

The <head> and <body> elements cannot be omitted, and the <title> element must be the first element in the <head> element.

Nested tags. Tags must be nested properly and all tags must have closing tags or be written in a form that combines the opening and closing tag.

Empty elements. Empty elements must either have an end tag, or the start tag must end with />. This is sometimes called a self-terminating element.

Element and attribute names. XML is case-sensitive, and the XHTML DTDs, element, and attribute names must be in lower case. All attribute values must be quoted in single or double quotes:

Nested elements. Elements must also be properly nested, so that closing tags must be in reverse order of the opening tags.

No minimized attributes. XML, and therefore XHTML, does not support attribute minimization.

Script and style tags. Because any < and & characters are considered parts of tags in XHTML, any script and style tag sections must be wrapped in a CDATA section to otherwise ignore characters that would normally be considered markup. The only delimiter that's recognized in a CDATA section is the "]]>" string that ends the section. You can also use external script and style documents to solve the problem, as illustrated in the following example:

<script language="JavaScript">
<!--
<![CDATA[
// JavaScript code
]]>
//-->
</script>

Return to main story, "XHTML: A Bridge To The Future."

Back to This Week's Issue
Send Us Your Feedback
Top of the Page

Get InformationWeek Daily

Don't miss each day's hottest technology news, sent directly to your inbox, including occasional breaking news alerts.

Sign up for the InformationWeek Daily email newsletter

*Required field

Privacy Statement



This Week's Issue

Technology Whitepapers

Featured Reports







Video