According to the HTML5 drafts, “A DOCTYPE is a required preamble”. The preamble DOCTYPE html> is recommended, but legacy doctypes are allowed as an alternative, though they “should not be used unless the document is generated from a system that cannot output the shorter string”.
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' 'https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
![Html5 doctype example pdf Html5 doctype example pdf](/uploads/1/2/5/8/125821507/100101656.png)
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.
- How to view the source code of a page, an important tool.
- You know one word in HTML5:
<!DOCTYPE html>
= 'HTML5' - and one grammar rule:
<!DOCTYPE html>
goes at the top of every page.
doctype declaration
Document Type Declaration
wikipedia
wikipedia
HTML 4.01
Hypertext Markup Language ver. 4.01
wikipedia · w3.org
wikipedia · w3.org
XHTML
Extensible Hypertext Markup Language
wikipedia · w3.org
wikipedia · w3.org
* Unlike earlier versions of HTML, in HTML5 the doctype declaration is case-insensitive.
In other words
In other words
<!doctype html>
works as well as <!DOCTYPE html>
.