If I put <!DOCTYPE>
in my HTML document then my browser will use HTML 5.0 to parse the document. If I don't use <!DOCTYPE>
then which version of HTML will be used to parse the document?

- 20,799
- 66
- 75
- 101

- 403
- 4
- 8
-
3It's honestly a crap-shoot depending upon the browser. It's not worth the headache further down the line. – Nathan Champion Jan 16 '19 at 05:44
4 Answers
If you don't specify a DOCTYPE
the browser may go into Quirk mode which behaves different in every browser.
Quirks Mode is a mode of operation of web browsers such as Internet Explorer (IE), Firefox, and Opera. Basically, Quirks Mode (also called Compatibility Mode) means that a relatively modern browser intentionally simulates many bugs in older browsers, especially IE 4 and IE 5.
Also, it's good to know what would happen, but you should remember to use it every time, it's in the html standard and you may have unexpected results if you omit it.

- 3,403
- 2
- 22
- 36
The browser will fall back to quirks mode. See it discussed/answered here:
what-happens-if-i-dont-put-a-doctype-html-in-my-code-will-it-make-any-major

- 1
- 1

- 53
- 8
<!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,...)

- 61
- 9
The declaration is first thing in the HTML document before any tag is defined. It is not an HTML tag but it is in an indication about the version of HTML used.
If you don't define it at the start then might be the browser may go into Quirks or Strict Mode.

- 152
- 10