Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index

XHTML 1.0 Tutorials - Document Structure and Head Level Tags

By: FYICenter.com

Part:   1  2  3   4  5  6 

(Continued from previous part...)

What is a Smallest Valid XHTML Dodument?

If you are interested to see the smallest, but valid, XHTML document, check this one:

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head><title/></head><body><p/></body></html>

But it is not that useful. It has an empty title and an empty body.

What Is Wrong with This HEAD Element?

If you have trouble passing the XHTML 1.0 validation on your head element, check the following common mistakes:

  • Missing the title element.
  • Not closing the meta element as <meta ... >. You must close all elements in XHTML documents.
  • Not closing the link element as <link ... >. You must close all elements in XHTML documents.
  • Extra text outside any tags in the head element.

What Happens If the TITLE Element is Missing?

XHTML 1.0 requires you write the title element inside the head element. If you forget to include the title element, the XHTML validator will return an error to you. Here is how you can test this yourself.

Go the W3 XHTML validator Web site: http://validator.w3.org/. Copy and paste the following sample HTML document to the input area:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <base href="http://dev.fyicenter.com/" />
  <meta name="Author" content="FYIcenter.com" />
  <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8" />
  <script type="text/javascript" src="_local.js"></script>
  <link rel="stylesheet" type="text/css" href="_fyi.css" />
 </head>
 <body>
 <p></p>
 </body>
</html>

Click the "Check" button, you will get the following error:

Error Line 12 column 7: end tag for "head" which is not 
  finished.
 </head>

What Happens If a META Element Is Not Closed?

Meta tags, link tags and base tags must be closed in XHTML documents. If you forget to close them like the HTML format, you will get validation errors. Try the following tutorial sample XHTML document on http://validator.w3.org/ to see what types of errors you will get:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>My First XHTML Document</title>
  <base href="http://dev.fyicenter.com/" />
  <meta name="Author" content="FYIcenter.com">
  <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8" />
  <script type="text/javascript" src="_local.js"></script>
  <link rel="stylesheet" type="text/css" href="_fyi.css" />
 </head>
 <body>
 <p></p>
 </body>
</html>

(Continued on next part...)

Part:   1  2  3   4  5  6 


Selected Developer Jobs:

More...