22.06.2015 Views

Step by Step HTML5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

14 Chapter 2<br />

Specifying the Document Type<br />

When creating an <strong>HTML5</strong> document, the first line of the document should be this tag:<br />

<br />

The DOCTYPE tag always begins with an exclamation point and is always placed at the<br />

beginning of the document, before any other tag. Most HTML tags are not case-sensitive,<br />

but the word DOCTYPE should always be uppercase.<br />

Using the DOCTYPE tag is like signing a contract. It is an optional tag, but when you use<br />

it, you are promising that your coding will conform to certain standards. When a Web<br />

browser encounters a DOCTYPE tag, it processes the page in standards mode. When it<br />

doesn’t encounter the DOCTYPE tag, it assumes that there is something quirky about the<br />

page, and processes the page in quirks mode. When the browser sees the tag , it assumes you are using <strong>HTML5</strong>.<br />

The distinction between standards mode and quirks mode came about in earlier days,<br />

when there were problems with standardization between Web browsers. In some browsers,<br />

to display pages properly, you needed to get a little creative with the HTML code.<br />

Modern HTML coding does not allow that, but some older pages still include these<br />

obsolete workarounds. By using the DOCTYPE tag, you are making a promise to the<br />

Web browser that there is nothing but pure HTML code in the page.<br />

Earlier versions of HTML used more complex DOCTYPE tags. If you’re using HTML Version<br />

4.01, the syntax for the tag is:<br />

<br />

If you’re using XHTML, the syntax for the tag is:<br />

<br />

Note If you are writing XHTML code, the DOCTYPE tag is required.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!