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>