|
I tried to validate my Web page and got the error "no document type." What does this mean?
The truth is that no Web page produced by FrontPage passes the well-formed HTML test. For starters, FrontPage never begins a page with a DOCTYPE declaration, so the validator immediately shoots out a "NO DOCTYPE FOUND!" message (complete with the alarmist capital letters). DOCTYPE is short for document type. This snippet of code tells the browser what version of HTML the page is written in. (The most recent HTML version sanctioned by the W3C is HTML 4.01. Past versions are HTML 3.2 and HTML 2.0, which can't handle more recent Web technology like CSS.) This way, in interpreting a Web page's HTML, the browser sticks to the established standards for that version of HTML. The advantage is that all browsers know what those standards are and there won't be so many differences between the way they interpret and display your page. When a browser renders (displays) a page that has a DOCTYPE declaration (in what's called "standards mode"), it ignores invalid tags or attributes.
So how could Microsoft decide to neglect such an important item? Well, you actually don't need a DOCTYPE declaration. If it's missing, a browser displays the page in quirks mode. Anything goes in quirks mode. If a tag or attribute isn't official HTML, the browser takes a crack at it anyway and tries to display all the elements it sees in a particular page. As you can imagine, in quirks mode, the page can look pretty different in each browser.
So what should you do? First, keep in mind that you don't really need a DOCTYPE, and adding one out of the blue can cause more problems than it solves. Pages that FrontPage creates may not follow the strict guidelines of "standards mode." If you insert a DOCTYPE declaration, then the browser expects your code to be in line with the version of HTML that you've specified. In other words, the browser won't display elements that aren't sanctioned. However, if you decide that you want to bring your HTML in line with strict W3C standards, you can add one. But which version of HTML should you tell the world you're using? To choose the correct DOCTYPE, visit W3C.org and read up on all your options. In most cases, you can probably use the following common declaration:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.
01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
That last line refers the browser to the DTD (document type definition) file that contains the standards. A DTD lists the legal elements that define document structure and syntax. There are different DTDs for framed pages. You can also choose from DTDs that enforce stricter adherence to the HTML version's standard. Read about the different types of DTDs on the W3C Web site (www.w3schools.com/tags/tag_doctype.asp)
Use Find and Replace (see Section 12.1.3) to add the declaration to existing pages. You add a DOCTYPE declaration at the very beginning of the pagebefore the first <HTML> tag. Make sure you include that last line with the URL. A DOCTYPE declaration must reference a DTD file. Without it, a browser reverts to quirks mode.
To automatically add the declaration to any of your future pages, create a FrontPage template (Section 11.5) or Dynamic Web Template (Section 11.5.3), add the declaration to it, and then use the template to create new Web pages.
Even if you decide you don't want to add a DOCTYPE, you can still validate your pages to look for other errors. FrontPage also helps you check pages with its accessibility checker (see the next section). But if you're legally required to make your pages accessible, you probably need to add DOCTYPE declarations to all your pages.
|