description & Usage
In order for browsers to understand what type of document to expect, we need to use a <!DOCTYPE> declaration.
A document can have various types, for example:
- HTML 5:
<!DOCTYPE html>
- HTML 4.01:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- XHTML 1.1:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Notes
Note: HTML documents must start with a <!DOCTYPE> declaration.
Note: This declaration must be placed at the top of the page before the <html> tag.
Note: Remember <!DOCTYPE> is a declaration and not a tag.
Note: The declaration is case-insensitive:
<!DOCTYPE html>
<!DocType html>
<!Doctype html>
<!doctype html>
Browser compatibility and Support
# | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
<!DOCTYPE> |