What is !Doctype html?

<!DOCTYPE html> is the first thing you write in your HTML program. But what does it mean?



First of all, let's make some things clear, <!DOCTYPE html> is not an HTML tag. So, keeping that aside, what <!DOCTYPE html> basically does is that it tells the browser which type of document to expect. It tells your browser that you're writing an HTML code so treat it like one.

Since the introduction of HTML5, things have become much easier for coders like you. An earlier version of HTML(like HTML4.01), you had to specify which doctype you were trying to use. Some examples:

  • HTML4.01 Strict: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  • HTML4.01 Transitional: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  • HTML4.01 Frameset: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
  • XHTML1.0 Strict: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  • XHTML1.0 Tansitional: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  • XHTML1.0 Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
  • XHTML1.1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
But again, these are just for your knowledge now as in HTML5, you just need to put in <!DOCTYPE html> before every code.

Happy coding😊,
SD

Comments