HTML and CSS Reference
This is perhaps one of those WTF? moments I mentioned in the
introduction. These three elements are (XHTML authors, are you
sitting down?) entirely optional, because browsers assume them
anyway. A quick glance under the browser hood with Opera
Dragonfly confirms this ( Figure 1.2 ).
FIguRE 1.2 Opera Dragonfly
debugger shows that browsers
add the missing elements.
Figure 1.3 shows it using the Internet Explorer 6 developer tools.
Because browsers do this, HTML5 doesn't require these tags.
Nevertheless, omitting these elements from your markup
is likely to confuse your coworkers. Also, if you plan to use
AppCache (see Chapter 7) you'll need the <html> element in
your markup. It's also a good place to set the primary language
of the document:
A visually-impaired user might come to your website with
screenreading software that reads out the text on a page in a
synthesized voice. When the screenreader meets the string “six”
it will pronounce it very differently if the language of the page is
English or French. Screenreaders can attempt to guess at what
language your content is in, but it's much better to unambigu-
ously specify it, as I have here.
FIguRE 1.3 Internet Explorer
6, like all other browsers, adds
missing elements in the DOM.
(Old versions of IE seem to
swap <title> and <meta> ,