2.13 Common issues: Formal grammars
Explanation
When developing websites it is highly recommended that each page has it's HTML code checked for validity. This can save hours in repair time when discovering faults and glitches. It also presents fewer problems on cross-browser cross-platform compliance.
The W3C provide a free online validator for both HTML and CSS. These validators will work with an online site or a locally held copy.
For simplicity we have created a page checker that runs all three of the above in a single frameset.
Prior to validation it is necessary for each page to have both a valid doctype and character encoding set.
Doctypes
Validating to a published formal grammar and declaring that validation at the beginning of a document lets the user know that the structure of the document is sound. It also lets the user agent know where to look for semantics if it needs to. The W3C Validation Service validates documents against a whole list of published grammars.
For example this page is XHTML strict and the doctype declared is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
Character encoding
The recommended character encoding is UTF-8.
This is declared:
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
Which is added in the head section of the code.
Who and what does this affect?
- Non-standard browsers.
- Assistive technologies.
- Cross-platform browsers.
WAI guidelines on formal grammers
- 3.2 Create documents that validate to published formal grammars. [NGfL warning]
Further information.
- A list apart: Fix Your Site With the Right DOCTYPE!.
- W3C: Document Character Set.
- W3C: Beyond validation.
- A web standards checklist
- Maccaws: What every web site owner should know about standards: A web standards primer
- Joel Spolsky: The absolute minimum every software developer must know about Unicode and character sets
- Jukka Korpela: A tutorial on character code issues.