Writing and validating a strict XHTML document
This tutorial focuses on writing and validating a strict XHTML document in:
- Windows
- Linux
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
- Open notepad by going to Start -> Programs -> Accessories -> Notepad OR go to Start -> Run - Type notepad and press Enter.
-
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>
-
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.
-
Open your web browser.
-
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.
-
You should now see an XHTML strict document in your web browser which looks like this:
The validation process
Now that you have written a strict XHTML document, it's time to validate it.
-
Go to the W3C Markup Validator, located at http://validator.w3.org.
-
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.
-
Locate the file on your hard drive, and when you are ready to validate the document, click the button that says "Check"
-
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.
-
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
-
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>
-
Save the file as strict.html
-
Open your web browser.
-
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.
-
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.
-
Go to the W3C Markup Validator, located at http://validator.w3.org.
-
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.
-
Locate the file on your hard drive, and when you are ready to validate the document, click the button that says "Check"
-
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.
-
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..




