Just use "<!DOCTYPE html>" for HTML 5
The <!DOCTYPE html>
document type declaration tag is one of the declaration tags in HTML and indicates that the content of the document is using HTML (Hypertext Markup Language) coding. The name parameter of the DOCTYPE declaration must be html
, matching the name of the top element of an HTML document. The PUBLIC ...FPI...
part of the declaration (<!DOCTYPE html PUBLIC ...>
) identifies older HTML versions and should no longer be included in the DOCTYPE declaration.
The DOCTYPE declaration comes after the xml declaration and optional xml-stylesheet processing instruction, and before the starting <html> tag.
HTML Best Practices - Why specify a DOCTYPE?
From the W3C Tips for Webmasters:
Why specify a DOCTYPE
? Because it defines which version of (X)HTML your document is actually using, and this is a critical piece of information needed by browsers or other tools processing the document.
Since the document type is needed by web browsers, viewers and other HTML parsing tools in order to properly interpret a document as a particular version of HTML, the information provided by the <!DOCTYPE html>
tag is especially significant in situations where there are no HTTP headers available or when the headers do not indicate an xHTML/XML media type such as application/xhtml+xml
. Therefore, the DOCTYPE declaration is an important element in HTML documents, especially when creating polyglot HTML documents.
How to verify the DOCTYPE is working right
To verify that the DOCTYPE on a web page is working, bring up the page in Firefox (on a Windows system). Look for the three indicators on the right hand side of the tool bar, as shown in the screen capture below. You can mouse over them to get a pop-up tool tip showing what the indicators mean. The first one should be a green check mark to indicate the page is being displayed in Standards Compliance Mode. The other two should also be green indicating the page is free from CSS errors and free from JavaScript errors, respectively.