Why do we need the tag after the declaration?


#1

Why do we need the tag after the declaration? This seems redundant. We tell the browser that it is dealing with an html file via the Doctype declaration; then we have to tell it again with the tag once it starts parsing the code? Can the function of tags not be passed off to the DTD?


FAQ: Learn HTML Elements - Common HTML Elements - The `<html>` tag
FAQ: Learn HTML Elements - Common HTML Elements - The `<html>` tag
#2

The DTD is not HTML, but SGML. It tells the user agent that the root element of the document is <html></html>. The de facto namespace is HTML5. Other than that the declaration has no part in DOM.


#3

Hey there, just started learning html but like Nathan here, I feel a redundancy in the writing. I’ve been reading your reply a couple of times but I’m still confused. I’m sure your answer is probably clear to most people here but if you were to bring it down a level from newbie 2.0 to newbie 1.0, what would it look like? Thank you


#4

3 On SGML and HTML

The above refers back to HTML 4.01 as it relates to SGML. HTML is a subset of SGML.

With the advent of HTML5 and the present day Living Standard a lot of the technical boilerplate was shooed into the background, such as the long and complex DTD and namespace declarations; and a number of meta data components such as ‘content-type’, etc. were made moot. That’s where the de facto aspect comes in.

<!DOCTYPE html>

Looks like an HTML comment, almost, doesn’t it? But it is not HTML, only an HTML DTD to declare the root element of the document. That is where the real HTML begins.

<html lang="en">
  <!-- everything in here is HTML -->
</html>