This exercise says that <!DOCTYPE html> “specifies the version of HTML for the browser”. What are the different versions of HTML and why do they exist?


#1

Question

This exercise says that “specifies the version of HTML for the browser”. What are the different versions of HTML and why do they exist?

Answer

These days most web developers use HTML5 but pre-HTML5 some common doctypes included HTML 4.01 Strict, HTML 4.01 Transitional, XHTML 1.0 Strict, and XHTML 1.0 Transitional. For example, the HTML 4.01 Strict doctype look like this:

A strict doctype validates differently than the more permissive transitional doctype.

FAQ: Learn HTML Elements - Common HTML Elements - Where Does the Title Appear?
#2

So if you type <!DOCTYPE html> the computer automatically knows that the html you are talking about is html5 or would you have to change the tag to <!DOCTYPE html5>???


#3

<!DOCTYPE html> is the doctype declaration for html5, then the browser will understand it can expect a html document which uses html5 standards

<!DOCTYPE html5> is non-existing, don’t use it


#4

The <! DOCTYPE> element is used to specify the type of the current document - the DTD (document type definition). This is necessary for the browser to understand how to interpret the current web page, since HTML exists in several versions, in addition, there is XHTML (EXtensible HyperText Markup Language), similar to HTML, but different in syntax. To the browser “did not get confused” and understood, according to what standard to display a web page and it is necessary to specify <! DOCTYPE> in the first line of the code.
Previously, the index file needed to write large lines like
<! DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.1 // EN “” http://www.w3.org/TR/xhtml11/DTD/xhtml11. dtd ">
Fortunately, with the advent of HTML5, everything became much simpler and the first line became significantly shorter: <! DOCTYPE html>


#5

To a computer, <!DOCTYPE html> = HTML5


#6

When you type the The computer basically knows you want what’s best which is the latest html. The latest in this case being html5, the computer will automatically use html5


#7

So in the future if a new version of html becomes the standard rather than html5, will simply typing indicate using that latest version? And if so, will you then have to specify html5 by using ?


#8

its difficult to say what w3c will do, only time will tell. But those guys know what they are doing, so surely they will do something sensible.


#10

HTML5 is the current Living Standard. As the post above reads, the user agent will always implement the latest recommendations. We will never have to specify HTML5, as it will always be able to run in any newer browser. HTML in its newest form is for the most part fully backward compatible.

Technically, when served as the default text/html it validates to HTML 4.01 specs, save for the new bits.

To clarify, not the computer… The browser. We should always keep our browser(s) up to date so the latest recommendations are available.


#12

The other DOCTYPEs for the various versions are:

HTML

  • HTML 4.01 transitional
  • HTML 4.01 strict
  • HTML 4.01 frameset
  • HTML 3.2

XHTML

  • XHTML 1.0 transitional
  • XHTML 1.0 strict
  • XHTML 1.0 Frameset
  • XHTML 2.0