XHTML, the latest version of HTML, is identical in almost every way to HTML 4.0 except for more restrictive syntax and a wider definition of white space. It is beyond the scope of this class to explore many of XHTML's details. If you are interested in a concise overview of some of XHTML's requirements, read "HTML and XHTML: The Definitive Guide", Chapter 16, for more information (note that I consider their conclusions regarding the feasibility of humans using XHTML coding practices as just plain WRONG; witness all the C, C++, Java, and JavaScript programmers who code by hand using much more restrictive languages and manage perfectly well). For the last word on XHTML and the official XHTML standards, visit the World Wide Web Consortium and read the documents concerning XHTML posted there: "http://www.w3.org/".
It is important for web programmers to follow XHTML coding practices as much as possible when creating HTML documents today, in order to make our "legacy" content readable by future browsers. Restrictive XHTML syntax will be the rule of law for web pages within a very few years, so follow the strictest possible syntax when coding HTML.
Remember the following rules about XHTML when coding your HTML:
All tags MUST close. If a tag doesn't ordinarily close (like BR
, IMG
, AREA
, etc), it must close within its opening tag using the space-close-slash shorthand closing syntax we've already learned.
Example:
NOT: <br>
CORRECT: <br />
NO text may sit, exposed, at the BODY level of the document. All text MUST be enclosed in some sort of tag, whether P, TH, ADDRESS, etc.
Example (incorrect):
<html> <head> <title>Wrong</title> </head> <body> Here is some text.<br /> Here is some more text.<br /> </body> </html>
Example (correct):
<html> <head> <title>Right</title> </head> <body> <p>Here is some text.</p> <p>Here is some more text.</p> </body> </html>
All attributes MUST follow the syntax outlined in an earlier module: attribute="value"
When an attribute does NOT have a value (such as the NORESIZE
attribute), the attribute value WILL be a restatement of the attribute name, i.e. noresize="noresize"
XHTML is case-sensitive, with an all-lower-case tag and attribute syntax. Therefore, we MUST use all-lower-case tag names when coding in HTML today.
Example (incorrect):
<P>Here is a paragraph of text.</P> <img SRC="./graphics/capitalA.gif" WIDTH="54" height="54">
Example (correct):
<p>Here is a paragraph of text.</p> <img src="./graphics/capitalA.gif" width="54" height="54" />
I know that this seems like I'm enforcing very nit-picky details, but these details will be CRITICAL to future browsers. XHTML is as restrictive, in terms of case sensitivity, as C, C++, Java, and JavaScript (which are all case-sensitive languages, as well), and people manage to code THOSE languages by hand successfully; you can too!
Well, those are the primary details concerning XHTML standards that I feel need to be stressed. I strongly recommend that you read up on XHTML at the World Wide Web Consortium website; I think you will find it a potentially tiresome but highly enlightening experience.
Copyright © 2001 Michael Masumoto. All Rights Reserved.