I'm working on several projects with HTML, and sometimes I forget to put <!DOCTYPE html>
. Will it make any big or noticeable changes?

- 1,041
- 3
- 11
- 21

- 361
- 1
- 4
- 11
-
2It can, yes. You can end up in browser compatibility modes. How this affects your page depends on what's on it. – Brad Apr 22 '14 at 21:46
-
3You will end up in the dreaded "quirks mode" - a broken and ill-defined place. See [Quirks mode and strict mode](http://www.quirksmode.org/css/quirksmode.html). For modern a HTML page, a [HTML5] DOCTYPE should always be present. – user2864740 Apr 22 '14 at 21:47
4 Answers
The <!DOCTYPE>
declaration must be the very first thing in your HTML document, before the tag.
The <!DOCTYPE>
declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
A lot of IDEs allow users to leave this out and default to a certain HTML style (possibly even inserting it automagically), but leaving it out does pose a potential threat in browser compatibility and the use of older versions of HTML.
For example: new features & tags in HTML5 such as <article>
,< footer >
, <header>
,<nav>
, <section>
may not be supported if the <!DOCTYPE>
is not declared.
Additionally, the browser may decide to automatically go into Quirks or Strict Mode.

- 1,740
- 6
- 19
- 33
-
1This article could be useful, complementing the last part of your answer :): http://jkorpela.fi/quirks-mode.html – ivanleoncz Nov 18 '17 at 22:03
-
1
-
All these answers seem dated now. Keeping IE aside (all versions, since you know, who cares), does the it even matter with the latest version of Chrome? If not, it should be treated as de-facto redundant. – Sujay Phadke Jul 23 '19 at 04:35
-
-
2The answer doesn't contain reply on the topic: what will happen if DOCTYPE will be missing? – Victor Ponamarev Jan 18 '20 at 11:34
In HTML documents, browsers use a DOCTYPE in the beginning of the document to decide whether to handle it in quirks mode or standards mode.
<!DOCTYPE html> // Tells the browser that we are using HTML5.
If document type is not mentioned, browser will go to Quirks mode. Quirks mode depends upon the web browser version, If is older version then this will not support HTML5 tags (Example: header tag, footer tag, section tag,...)
To see the different between the Quirks mode and Standard mode visit : https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode
If you want to try this one use the below code with and without
<!DOCTYPE html>
in your older browser like IE 8 or earlier
`<video controls>
<source src="../videos/big_buck_bunny.mp4" type="video/mp4">
<p>Your browser does not support H.264/MP4.</p>
</video>`
//Note : In the above code src="give your local mp4 video link in your computer"

- 554
- 4
- 9
-
1`If document type is not mentioned, browser will go to Quirks mode.` Can you provide a reference that says that this is guaranteed to happen, and that Quirks mode is always noticeably worse than standard mode, even if the content otherwise is perfectly valid XHTML, and html tag even includes `xmlns="http://www.w3.org/1999/xhtml"`? – Dmytro May 16 '18 at 19:19
-
2Hello @Dmitry, Thanks for raising the question on this discussion.I hope this will help you : https://www.w3.org/wiki/Doctypes_and_markup_styles#Standards_versus_quirks_mode – Muthukumar Jun 01 '18 at 01:32
DOCTYPEs are required for legacy reasons.
When omitted, browsers tend to use a different rendering mode that is incompatible with some specifications.
Including the DOCTYPE in a document ensures that the browser makes a best-effort attempt at following the relevant specifications.
for more details: http://www.w3.org/TR/html5/syntax.html

- 3,541
- 28
- 38
- 38

- 651
- 1
- 6
- 13
in some cases, the DOCTYPE is not the very first line in a HTML document, for example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
...

- 151
- 2
- 12
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 28 '21 at 10:09