HTML and CSS Reference
First things first: the DOCTYPE:
That's it. No unwieldy string that even the most prolific web
authors need to cut and paste. No URLs. No version number.
That's all. It's not so much an instruction as an incantation: it's
required by browsers that need the presence of a DOCTYPE to
trigger standards mode, and this is the shortest string that does
this reliably. We've written in uppercase so that it's both HTML
and XML compliant, and suggest you do the same.
Then we need to define the document's character encoding.
Not doing so can result in an obscure but real security risk (see
be in the first 512 bytes of the document. Unless you can think
of a splendid reason not to use it, we recommend UTF-8 as the
Ta k e a l o o k a t t h a t <meta> tag very carefully. Those who are
accustomed to writing XHTML will notice three oddities. The first
is that the <meta> tag is much shorter than the tag we are famil-
iar with— <meta http-equiv=”Content-Type” content=”text/html;
charset=UTF-8”> . This is still possible, but the shorter way is bet-
ter as it's easier to type and works everywhere already.
Yo u ' l l a l s o n o t i c e t h a t I h a v e n ' t q u o t e d t h e a t t r i b u t e
charset=”utf-8” . Neither have I self-closed the tag <meta
charset=utf-8 /> .
HTML5 is not an XML language, so you don't need to do those
things. But you can if you prefer. All of these are equally valid
<META CHARSET=UTF-8 />
<META CHARSET=”UTF-8” />
<meta charset=utf-8 />
<meTa CHARset=”utf-8” />