Web Access Centre
Doctypes - Web Access Centre
Summary: Pages for the web are written in various markup languages, such as HTML and XHTML all of which need to be declared so the browser can interpret the pages correctly.
- Rationale
- Techniques
- Testing tips
- Further information
- Website Accessibility Initiative compliance
- Other pages about layout and structure

Rationale
Every page should have a valid Document Type Definition (DTD) and encoding declaration. The doctype declaration refers to a published code standard (Document Type Definition or DTD) to which the page claims conformance and its provision can enable modern browsers to better render the content being provided. Access technology such as speech or braille output will also be able to interpret the pages correctly.
Pages will validate properly, and display correctly in different browsers. If the DTD and the default encoding are not declared, or are incorrectly declared, the page will fail validation and the browser may not display them correctly.
Techniques
- Doctype code must be the very first thing declared on each page, with nothing preceding it (including blank lines). The simplest initial choice of doctype is currently “HTML 4.01 Transitional”. Ensure also that the DOCTYPE appears at the top of the HTML.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- Frameset doctypes should use the “HTML 4.01 Frameset” DTD should be used:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
- Validate your page with the latest versions of W3C (World Wide Web Consortium) technologies where possible. Using obsolete or deprecated technologies, for example, older versions of HTML can then be highlighted and removed.
Testing tips
Verify that there is a valid DOCTYPE on every page of your site.
- Automated tools - Missing DOCTYPES can be picked up by testing tools. The W3C HTML validator (see Further information below) can also be used to check your code to ensure the doctype is correct and valid.
- Accessibility toolbar - Go to Validate - W3C HTML Validator AND Validate W3C CSS Validator.
- Browser - Go to View - Source and check that the first link of code is a DOCTYPE
Further information
- Recommended DTD's to use on your website - from the W3C, the World Wide Web Consortium.
- W3C HTML validator - checks for valid DOCTYPES.
Website Accessibility Initiative compliance
- 3.2 Create documents that validate to published formal grammars. Priority 2
- 11.2 Avoid deprecated features of W3C technologies. Priority 2
- 11.1 Use W3C technologies when they are available and appropriate for a task and use the latest versions when supported. Priority 2
For more information on techniques visit the Web Accessibility Initiative techniques page.
Other pages about layout and structure
- CSS
- Data tables
- Doctypes
- Frames
- Layout tables
- Metadata
- Structure
Back to Design & Build
For Web Access Centre updates email webaccess@rnib.org.uk
Content author: webaccess@rnib.org.uk
Last updated: 06/03/2008 15:41
More info
Latest updates
Related info
Your stories
JK Rowling's story - when JK Rowling had her website redesigned she asked design agency Lightmaker to push the boundaries of accessible Flash. The original site offered the user an intensely visual experience. The new site needed to keep the explorative and creative elements but present them in a universally accessible way. Find out about the key features of the site and how it was designed. JK Rowling's accessible Flash website - full story