HTML5 tutorial - HTML5 doctype declaration

The doctype declaration tells the computer what type of html the page is written in - in this case HTML5

Take a look at this page's "Source Code". The source code is the HTML that generates a page.

On a PC in Chrome or FireFox right click anywhere on the page (except the ads) and select "View page source", or even easier just click "Ctrl-U". In IE "Ctrl-U" doesn't work; you have to right click the page and select "View Source". Select it all, copy it and paste it into Notepad or some text editor. If you have any problems or are in a different browser search "source code" in help.

At the very top of the page you will see the doctype declaration:

<!DOCTYPE html> *

Like any language, HTML5 has a grammar and a vocabulary.

Grammar
<!DOCTYPE html> goes at the top of every HTML5 page.
Vocabulary
The HTML5 word <!DOCTYPE html> means "this page is written in HTML5" as opposed to, say HTML 4.01.

Why, you ask, don't they just write <HTML5> or even a zesty <!HTML5>? I have absolutely no idea. Still it's better than what they had before. Here's an example of one common type of XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Hopefully the doctype declaration in HTML5 won't turn into the crazy mess it did with XHTML and previous versions of HTML. Those in charge of such things say it won't, but time will tell.

So now you learned three things:
  1. How to view the source code of a page, an important tool.
  2. You know one word in HTML5: <!DOCTYPE html> = "HTML5"
  3. and one grammar rule: <!DOCTYPE html> goes at the top of every page.

doctype declaration

Document Type Declaration
wikipedia

HTML 4.01

Hypertext Markup Language ver. 4.01
wikipedia · w3.org

XHTML

Extensible Hypertext Markup Language
wikipedia · w3.org

* Unlike earlier versions of HTML, in HTML5 the doctype declaration is case-insensitive.
In other words <!doctype html> works as well as <!DOCTYPE html>.