XHTML 1.0 Strict in a nutshell
Developing Internet sites or applications today is all about standards. And currently the most accepted standard for HTML is XHTML 1.0 Strict.
You have to define this in the <!doctype> declaration of the HTML page.
Benefits of choosing XHTML 1.0 Strict
Omitting the doctype makes browsers render html pages according to their own history. This means: all different, so you have to use CSS hacks almost everywhere to make your pages look the same in all browsers. This is called 'Quirks mode'. Putting in a standard XHTML doctype declaration in your pages however makes all browsers switch to standards compliant mode. This is a huge benefit: no more CSS hacks. Well... at least a lot less.
Another benefit: since the rules for XHTML are less complicated, all browsers render the pages faster. And when you replace the doctype by <?xml version="1.0"?> and render it as XML (mimetype: text/xml), the entire page can be processed as a valid XML document.
XHTML 1.0 Strict page skeleton
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Domino 2.0 - Making Domino render XHTML 1.0 Strict</title>
</head>
<body>
</body>
</html>
- The
<!doctype>has to be the very first thing on the page, and it is very case sensitive! - The root node has to be
<html>, with exactly one<head>and one<body>element. - It is a good practice to declare the character encoding as the first tag in the
<head>node. UTF-8 is the standard and an absolute must if you want to make Greek, Russian, Japanese, Chinese etc. correctly. - The
<title>tag is mandatory.
This is the basic XHTML compliant page structure. Any addition to it is pure overkill and even can confuse some browsers.
The basic rules of XHTML 1.0 Strict
- All tags and attribute names have to be lowercase.
- All tags have to be properly nested.
- Tags without inner content have to close themselves:
<img src="..." /> - All attributes have to have values enclosed in quotes. Attributes which don't have a value repeat the attribute name, e.g.:
selected="selected" - There is a limited number of tag names you are allowed to use.
- For each tag, there is a limited number of attributes allowed.
Validating your code
This is very simple. Just add <a href="http://validator.w3.org/check?uri=referer">XHTML 1.0 Strict</a> to your live page.
Comments
04/09/2007 16:18:06, Fred Janssen
OK, so XHTML 1.0 Strict is the name of the game. First thing I ran into when running my code through a validator is the target="_blank" in anchors. When looking at your source code I could only find a class="external" which seems to add the icon. How do you get the browser to open in a new window?
Fred
04/09/2007 19:22:39, Michel Van der Meiren
I run a small JavaScript function on page load that looks for links with className "external" and adds the target="_blank" to these links.
06/09/2007 16:47:37, Fred Janssen
That sounds like a hack to just to avoid the limitation in XHTML Strict, in other words cheating ? ;-) Did you describe this somewhere?
Fred
06/09/2007 18:39:30, Michel Van der Meiren
I'ts a hack indeed. But it makes sense: XHTML Strict wants to be platform-independant, and I add a browser-specific feature back in with non-obtrusive JavaScript. It is explained in blog.lotusnotes.be/domino/archive/2006-10-31-unobtrusive-ajax.html, although I now use a slightly different method.
06/09/2007 22:17:14, Fred Janssen
Thanks for the link and today's blog... Fred
To add a comment, log in or register as new user. It's free and safe.