USE DOCTYPE STATEMENTS

The first line of code in the previous example

<!DOCTYPE HTML PUBLIC 
"-//W3C//DTD HTML 4.01 Transitional//EN">

is a DOCTYPE statement. A DOCTYPE tells the browser which version of HTML you're using in the page. You don't have to use a DOCTYPE statement, but it's definitely recommended for the following reasons:

  • A DOCTYPE helps the browser process your page, and display it in the way you intended.
  • To use the features of the DOM (Document Object Model) to create interactivity and to create dynamic combinations of CSS (Cascading Style Sheets) and JavaScript effects on your pages, your code must be Web-standards compliant. The DOM is discussed further in Lesson 6. Web standards are the specifications created by the W3C (World Wide Web Consortium) for HTML, CSS, XML (Extensible Markup Language), and many other languages.

A full discussion of Web standards isn't within the scope of this course, but for more information, take a look at:

You can use The W3C Validation Service to check your pages for Web-standard compliance.