The DOCTYPE declaration optionally appears at the start of an HTML document. It comes from the Standard Generalized Markup Language (SGML) that was used to define previous versions of HTML in terms of the language syntax.
The DOCTYPE is used by HTML validation services to determine which version the document uses.

  • The doctype for HTML4.01 looks like this.
         <!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.01//EN"

  • The doctype for XHTML1.0 looks like this.
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN"

  • And here is the doctype for HTML5
         <!DOCTYPE html>

You can see that the HTML5 DOCTYPE is much shorter, easier to type, and easier to remember.

No comments: