HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / HTML5 / HTML5 DOCTYPE Declaration Example

HTML5 DOCTYPE Declaration Example

Technically, to parse and display a page correctly, a browser needs to know the DOCTYPE type of HTML document which tells the browser which version of HTML it should expect in the document.

Before HTML5, DOCTYPE declaration refers to a DTD, because it was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.

HTML5 is not based on SGML, and therefore does not require a reference to a DTD. So HTML5 simplifies the DOCTYPE to:

//In HTML5
<!DOCTYPE html>

in comparison to more complex declaration used before till HTML 4:

//BEFORE HTML5, Till HTML 4.0.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The DOCTYPE declaration is NOT case sensitive.

Please remember that DO NOT leave any spaces before the DOCTYPE tag else even a single space may cause errors in browser rendering of the HTML5 code.

Happy Learning !!

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.
TwitterFacebookLinkedInRedditPocket

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Comments are closed on this article!

Search Tutorials

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Sealed Classes and Interfaces