The Advantages of Using Valid HTML
HTML standards were developed to make it easy to share and process electronic documents regardless of the type of device, computer platform or operating system used.Using valid HTML is the first step to creating accessible pages. Valid HTML pages are pages that adhere to a set of rules defined by the World Wide Web Consortium (W3C): these rules describe:
- the structure of HTML documents
- the elements that can be used
- their attributes
- their syntax
Because HTML has been updated on many occasions, there is more than one set of rules, i.e. one set for each version. The rules for each version are encapsulated in documents called Document Type Definitions (DTD).Every web page should contain information about the appropriate DTD being used. The DTD should be the first element at the top of every page. This is important for the following reasons:
- So that newer browsers can change their behavior in accordance with the version of HTML you are using.
- Without the correct DOCTYPE browsers may not render your web page correctly.
- So that validation services such as the one provided by the World Wide Web Consortium can check if the HTML on the Web page conforms to the stated standard.
HTML 4.01 Document Type Definitions
HTML 4.01 can be validated against three Document Type Definitions. Assuming you are coding you pages to the latest version of HTML at the top of the page you should have one of the following DTDs.
1. Strict HTML 4.01 does not allow the use of deprecated elements attributes or the use of framesets. The document definition used to indicate that a page has been marked up in this way is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2. Transitional HTML 4.01> allows the use of deprecated elements and attributes but framesets are not allowed:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3. Frameset HTML 4.01 allows the use of framesets and deprecated elements and attributes:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
Currently the most common DTD used is 'Transitional HTML 4.01' - which means that you have to code your pages as valid HTML version 4.01 but you are allowed to use deprecated elements such as the font tag.
XHTML 1.0 Document Type Definitions
"The XHTML family is the next step in the evolution of the Internet. By migrating to XHTML today, content developers can enter the XML world with all of its attendant benefits, while still remaining confident in their content's backward and future compatibility. " W3C XHTML 1.0 Documentation
Use XHTML 1.0 Strict when you need clean structural markup, and complete separation of presentation and document structure. The downside is that if you make mistakes in your markup the page will not display at all in many browsers.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
For general web use, XHTML 1.0 Transitional is a good choice, as markup can be adjusted to accommodate older browsers while still remain standard compliant. Use of XHTML 1.0 Transitional encourages separation of presentation and structure, and the use of style sheets to alter presenation.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 Frameset is the appropriate DTD if you need to use frames in your web pages.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Why build websites using valid markup?
- Today's browsers largely support HTML standards; both Netscape and Explorer have committed themselves to supporting the W3C standards.
- According to The Web Standards Project, supporting incompatible browsers adds an average 25 percent to site budgets.
- invalid markup affects document portability, interoperability, and the future value of your content .
- When developing sites using CSS, invalid HTML, like overlapping tags and unclosed elements, will produce unpredictable results.
- Standards based websites are likely to be more accessible. If you are focusing on making your pages work on just one specific browser, you may be locking out surfers with special technologies, or alternative browsers. Most current and past browsers will try to interpret invalid HTML, but there is no assurance that next generation browsers will be as forgiving.
- Organizations risk making their documents obsolete by not ensuring that their web documents adhere to the HTML specification.
- By working to the HTML specification you make it easier to transport HTML documents to others for revision and re-purposing.
The Web Standards Project (WASP) http://webstandards.org/
The Importance of Valid HTML: http://www.hotmetalpro.com/resources/html/validhtml.htm
Web standards for hard times; http://hotwired.lycos.com/webmonkey/02/33/index1a.html