/ factorpad.com / tech / html5 / reference / html-doctype-declaration.html
An ad-free and cookie-free website.
Beginner
The !DOCTYPE
declaration is one of
several required lines at the beginning of an HTML document.
The !DOCTYPE
declaration instructs the
browser as to what document type and version to expect, so it knows how
to render the content. It must be present at the beginning of the
document.
The !DOCTYPE
declaration is
self-closing and does not require an ending tag.
The !DOCTYPE
declaration is case
insensitive, so it can also be input as
!doctype
and includes the type
of document. In this case we are referring to HTML5, so we use
html
as the document type, which is
also case-insensitive. The following is the most common format.
In a more strict markup called XHTML, both
DOCTYPE
and
html
are case-sensitive.
The !DOCTYPE
declaration is
specified uniquely for each of several HTML and XHTML versions, as
listed below.
Version | Format |
---|---|
HTML 5 | <!DOCTYPE html> |
HTML 4.01 | <!DOCTYPE html PUBLIC
"-//W3C/DTD HTML 4.01//EN"> |
HTML 4.0 | <!DOCTYPE html PUBLIC
"-//W3C/DTD HTML 4.0//EN"> |
XHTML 1.1 | <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
The following !DOCTYPE
declaration is
valid (and most common) for HTML5.
Due to case-insensitivity in HTML5, the following is also correct, but less common.
The !DOCTYPE
declaration is paired
with other essential tags that should be included in every HTML
document.
Our growing YouTube Channel offers other helpful and free ways to learn. For reminders, subscribe and follow before you get distracted.
<!-- comment -->
tag works. Click Next./ factorpad.com / tech / html5 / reference / html-doctype-declaration.html
A newly-updated free resource. Connect and refer a friend today.