Programming

Programming intro
Java

Markup

First webpage guide
HTML
XHTML

Style & Layout

CSS

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

Writing and validating a strict XHTML document

This tutorial focuses on writing and validating a strict XHTML document in:

Windows

Consideration

Consider first, if the XHTML document you are creating should be a strict XHTML document, and not one of the other XHTML document types. A strict XHTML document is one that contains really clean markup with no presentational clutter, and does not use any deprecated features such as HTML's <font> tag. The strict document type should be used together with Cascading Style Sheets. If you are writing an XHTML document with this purpose in mind, then it should indeed be a strict XHTML document. Otherwise, you may want to use one of the other XHTML document types. To learn more about the different XHTML document types, read our XHTML document type definition lesson.

The writing process

  1. Open notepad by going to Start -> Programs -> Accessories -> Notepad OR go to Start -> Run - Type notepad and press Enter.
  2. Type in the following code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
    1.0 Strict//EN" "http://www.w3.org/TR/
    xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Strict document</title>
    </head>
    <body>
    <h1>
    This is a strict XHTML document.
    </h1>
    </body>
    </html>
    
  3. Save the file as strict.html

    NOTE: Make sure that you give the file a .html extension and that you save it as type 'All Files', otherwise you will get plain text.

  4. Open your web browser.

  5. Type into the web browsers location bar the absolute location of the directory where you saved your file along with the file name. For example, if you saved the file in C:\windows, type C:\windows\strict.html into the web browsers location bar.

  6. You should now see an XHTML strict document in your web browser which looks like this:

    Document result

The validation process

Now that you have written a strict XHTML document, it's time to validate it.

  1. Go to the W3C Markup Validator, located at http://validator.w3.org.

  2. The W3C Markup Validator gives you the option of validating a document by URL, by File Upload, or by Direct Input. In this tutorial, you will be validating the document by File Upload. Find the label that says "Local File:" and click the button that says "Browse...." which is directly parallel to it.

  3. Locate the file on your hard drive, and when you are ready to validate the document, click the button that says "Check"

  4. If the document did not validate, you should get a message saying "This page is not Valid XHTML 1.0 Strict!"

    Possible reasons for the document not validating:

    • Missing closing tags
    • Tags not closed in the right order
    • Attribute values not quoted properly
    • You used one of HTML's deprecated tags such as <font>
    • A missing <!DOCTYPE> declaration

    Read the description of the error(s) that the Markup Validator provides. It is usually very descriptive.

  5. If the document did validate, you should get a message saying "This Page Is Valid XHTML 1.0 Strict!"

    You now have a valid XHTML strict document!! This means "that you have taken the care to create an interoperable Web page" as is stated by the W3C Markup Validator.

Linux

Consideration

Consider first, if the XHTML document you are creating should be a strict XHTML document, and not one of the other XHTML document types. A strict XHTML document is one that contains really clean markup with no presentational clutter, and does not use any deprecated features such as HTML's <font> tag. The strict document type should be used together with Cascading Style Sheets. If you are writing an XHTML document with this purpose in mind, then it should indeed be a strict XHTML document. Otherwise, you may want to use one of the other XHTML document types. To learn more about the different XHTML document types, read our XHTML document type definition lesson.

The writing process

  1. Open nano and type in the following code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
    1.0 Strict//EN" "http://www.w3.org/TR/
    xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Strict document</title>
    </head>
    <body>
    <h1>
    This is a strict XHTML document.
    </h1>
    </body>
    </html>
    
  2. Save the file as strict.html

  3. Open your web browser.

  4. Type into the web browsers location bar the absolute location of the directory where you saved your file along with the file name. For example, if you saved the file in /home/user1/desktop, type /home/user1/desktop/strict.html into the web browsers location bar.

  5. You should now see an XHTML strict document in your web browser which says "This is a strict XHTML document."

Screenshot for Linux coming soon..

The validation process

Now that you have written a strict XHTML document, it's time to validate it.

  1. Go to the W3C Markup Validator, located at http://validator.w3.org.

  2. The W3C Markup Validator gives you the option of validating a document by URL, by File Upload, or by Direct Input. In this tutorial, you will be validating the document by File Upload. Find the label that says "Local File:" and click the button that says "Browse...." which is directly parallel to it.

  3. Locate the file on your hard drive, and when you are ready to validate the document, click the button that says "Check"

  4. If the document did not validate, you should get a message saying "This page is not Valid XHTML 1.0 Strict!"

    Possible reasons for the document not validating:

    • Missing closing tags
    • Tags not closed in the right order
    • Attribute values not quoted properly
    • You used one of HTML's deprecated tags such as <font>
    • A missing <!DOCTYPE> declaration

    Read the description of the error(s) that the Markup Validator provides. It is usually very descriptive.

  5. If the document did validate, you should get a message saying "This Page Is Valid XHTML 1.0 Strict!"

    You now have a valid XHTML strict document!! This means "that you have taken the care to create an interoperable Web page" as is stated by the W3C Markup Validator.

Mac

Coming soon..

Step-by-step tutorials
Programming intro
HTML
XHTML
CSS
Javascript
Java

Practice

Online code editor
Practical examples
Practical exercises

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments