0

Do I need to write <!DOCTYPE HTML> at the top of every page? I don't do it at the moment and everything seems to work fine. What is the purpose of it, if we already have <html>?

  • 3
    Possible duplicate of [Why do I need a doctype? (What does it do)](http://stackoverflow.com/questions/6076432/why-do-i-need-a-doctype-what-does-it-do) – Justinas Jun 22 '16 at 06:18
  • 2
    Possible duplicate of [What is the functionality of !DOCTYPE?](http://stackoverflow.com/questions/1818587/what-is-the-functionality-of-doctype) – Rando Hinn Jun 22 '16 at 06:20

3 Answers3

3

It is an instruction to the web browser about what version of HTML the page is written in. The <!DOCTYPE html> is standard for HTML 5. Hope this link help you HTML Declaration

Engkus Kusnadi
  • 2,386
  • 2
  • 18
  • 40
0

Yes, it is. Otherwise browser will default to Quirks Mode:

References:

Why do I need a doctype? (What does it do)

Why do I need a doctype? (What does it do)

Community
  • 1
  • 1
Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73
-1

It isn't required as such, world won't end and neither will your code if you don't have it. However, it gives the browser information to what HTML version you are using and not having it can create some issues further on, especially if your sites get larger amounts of code and complexity, and thus is recommended to add to your code.

Xariez
  • 759
  • 7
  • 24
  • @Dmitry Sorry for the delayed reply. Looking back at it i see how extremely vague my reply was, so thanks a lot for filling it in! – Xariez Jun 06 '18 at 13:20
  • In hindsight my comment was inept I apologize for having you read it. – Dmytro Jul 31 '22 at 08:01