decorative banner

Setting the doctype of a document


    A document's doctype, which is specified in the !DOCTYPE declaration at the beginning of the document, tells HTML validators and browsers which Document Type Definition (DTD) to use when handling the document. The DTD specifies the elements that are allowed in the document and the attributes for each element. For example, the HTML 4.0 Strict DTD doesn't allow frames in documents, and the XHTML Basic DTD doesn't allow font elements.

    By setting a document's doctype, you are declaring that the document complies with a particular DTD, which some devices now require. Some cell phones, for example, require documents to comply with the XHTML Basic DTD. If you are designing a document for display on cell phones, be sure to set the doctype of the document to XHTML Basic. Most current versions of browsers can display documents that are not compliant with the document's declared DTD. But, by setting the doctype and making sure the document is compliant, you are preparing the document for future versions of browsers that will require compliance. If a document doesn't have a doctype, which is the case for most older documents, browsers can still display the document.

    Tip iconIf you set a document's doctype and then use the Syntax Checker, GoLive checks the document's structure and syntax, and then highlights any elements that are not compliant with the DTD declared in the doctype. (See Checking syntax.)

Related Subtopics: