What is validating?

Validating ensures that your page is consistent with the World Wide Web Consortium (W3C) recommendations for HTML. This makes it more likely that your page will work on other browsers, and on browsers of the future. Here is a link with more information on validation. The latest recommendation from the W3C is HTML 4.0. There are three versions of HTML 4.0: strict, transitional (loose), and frameset.

How do I validate my HTML page?

  1. First, choose your version (we recommend strict) by adding one of the following three lines of code to the very top of your HTML file. (Hint: You can view the source code of this page and see that the top line matches the strict one below.)

    for Strict

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    for Loose

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

    for Frameset

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">

  2. Second, add this line in the HEAD section of your page:
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
  3. Go to this page: http://validator.w3.org/
  4. This takes you to a page that looks like this:
    W3C validation screen
    You can type in the URL of this web page (http://cs.wellesley.edu/~cs110/assignments/assignment1/validate.html) in the box and then click on the "Check" button. (Note that there is also a tab to validate via file upload.)
  5. There are two different ways to validate: by supplying the URL, or by file upload:
    • Validating by Supplying the URL
      In the box next to Address:, type in the URL of your page, e.g. assign1.html (note that your page must be uploaded to the cs server before validating this way).
      OR
    • Validating by File Upload
      Alternatively, you can click on the "Validate by File Upload" tab and validate a file on your desktop. This is necessary for homework assignments that are uploaded to your protected folder. In Firefox, select File >> Save Page As. This opens a window that looks like this:
      saving page in Firefox
      Make sure you are saving your HTML page on the Desktop and that the format is Web Page, complete. Then, you can browse to your document on the Desktop and validate via File Upload.
  6. Click on the "Check" button, and this page lets you know about any errors found on your page. If there are no errors, then it will indicate so with a success message.
  7. If there are errors on your page, work through them one by one.
  8. Continue working through the errors and revalidating until you get the success message.
  9. The success page gives you a snippet of HTML code that you can add to your page to indicate that your HTML has been validated. Make sure you copy and paste the snippet of code so that your page has the icon at the bottom (like this page does).



© Computer Science 110 Staff
Date Created: June 8, 1998
Last Modified: 27 January 2009

Valid HTML 4.01 Transitional