"<!DOCTYPE html>"
Tags: beginners, html, css
Published: 2020-11-29 07:13:53

When i started learning html few days ago, i used to forget mentioning `<!DOCTYPE html>`.

I thought learning more about it, i will start forgetting less.

So, What does it mean ? What happens if you don't or want to write ? Why should you  write it at all ? and also in the beginning of the file and not in second line or after.

> ```<!DOCTYPE html> ```

>`<! >` markup declaration, that is carried forward from earlier versions of HTML. To let browser know that, `<! This is HTML version x.x document !>` or  `<!-- This is comment -- >`

>`DOCTYPE` - Documentation Type

>`html` - version of HTML. Here it means HTML5.

### Some History
Back old days, Web Browser was first developed in 1990 and [NCSA Mosaic](http://www.ncsa.illinois.edu/enabling/mosaic) was the first browser to display images and text simultaneously and led to the Internet Boom.

`Netscape Navigator` developed by Netscape which employed many of the original Mosaic authors. Firefox is the successor to Netscape, as the Mozilla community was created by Netscape in 1998 before their acquisition by AOL.

Spyglass, Inc. licensed the technology and trademarks from NCSA for producing its own web browser, Microsoft  [licensed](https://en.wikipedia.org/wiki/Mosaic_(web_browser)) Spyglass Mosaic and later purchased.

Among few other players, Netscape and Microsoft had majority market share. Both Microsoft and Netscape liberally incorporated proprietary extensions to HTML in their products, and tried to gain an edge by product differentiation.

If you want more on this,  [this](https://en.wikipedia.org/wiki/History_of_the_web_browser) is the place.

Though W3C is in place many did not follow while developing their browsers.  [Here](https://www.w3.org/QA/2002/04/Web-Quality)  you can find what others opined back then.

### Back to Present

Major upgrade of HTML Web Standards is v5.0 (W3C and WHATWG were working together)

W3C earlier documented all the standards/api's at  [WebPlatform](https://webplatform.github.io/)  and Later moved to  [MDN](https://en.wikipedia.org/wiki/MDN_Web_Docs) 

As of today, Most of the browsers support these recommended standards, called `Full Standards Mode` i.e., the behavior described by the HTML and CSS specifications

So by writing `<!DOCTYPE html>` in the first line of your file, you are telling the Browsers to render the content based on the Full Standards Mode.

Here comes other 2 modes
-  [Quirks Mode](https://developer.mozilla.org/en-US/docs/Mozilla/Mozilla_quirks_mode_behavior)  
 - this emulates browser behaviour as that of old legacy browsers.
-  [Almost Standards Mode](https://developer.mozilla.org/en-US/docs/Mozilla/Gecko_Almost_Standards_Mode)  
 - this has few behaviours implemented from Quirks mode.

The only purpose of DOCTYPE is for the browser is to know on which mode rendering has to be. (and as to prevent entering Quirks mode as default).

Even if you write a comment on the first line and second line as DOCTYPE, your browser will enter quirks mode, and you will see unexpected behaviour.

But what if you want to support your content on old Browsers i.e., before HTML 5.0, Nah. There is no reason that you want to spin your head on that. 
But if you want to really to support Legacy browsers or give a try, [this](https://html.com/tags/doctype/) is the link.