Why do we need the tag after the declaration?

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?

13 Likes

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.

11 Likes

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

18 Likes

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>
14 Likes

mark <body< and win the coding winning storke

Hello newbie 1.0 :slightly_smiling_face:, as a member of the newbie 2.0 squad myself, i totally understand you. So I hope this helps: As you know, is not a HTML tag, but rather, just a message to the web browser telling it what it’s looking at and dealing with. On the flip side, thing tag serves as a container, this ‘container’ serves as a ‘bracket’ (for lack of a better word. What this bracket does is tell the web browser that the opening and closing tags are where all related code will begin and end. I hope this helps. Cheers

40 Likes

Hi, Roy. I am still confused about the concept of DTD. I heard that HTML 5 is not based on SGML, so there is no requirement to quote DTD. And Here is what I find in the Stackoverflow say that there is no HTML5 DTD( DTDs have been regarded by the designers of HTML5 as too limited in expressive power, and HTML5 validators (basically the HTML5 mode of http://validator.nu and its copy at http://validator.w3.org/nu/) use schemas and ad hoc checks, not DTD-based validation. Moreover, HTML5 has been designed so that writing a DTD for it is impossible. ). :confounded:This is completely confusing for a newbie 1.0 like me.

Could you please elaborate on the relationship between DTD and HTML 5? AND what is the role of the DTD in detail?

No. I think you’ve done enough already in terms of following up on the details to arrive at a conclusion.

However, DTD is SGML, not HTML. The current one is the compromise. No DTD can be used to describe HTML5. but we can describe the root element, html.

<!DOCTYPE html>

and then rely upon the local namespace to provide all the support, which is what is happening.

Don’t forget that HTML5 is XML compliant, which as it happens does include the DTD since modern XML has absorbed SGML. What we have is an XML document that gets defaulted to text/html if not specified otherwise.

Doctype declaration <!DOCTYPE html> tells the user agent that the root element of the document is <html></html> . Is this redundant? Cuz it is very obvious that <HTML> </html> is root element.

AND what is the relationship between SGML and HTML 5? I know that XML is a simplified modification of SGML, and SGML is the parent of XML and HTML.

No it’s not. A malformed page would suggest that the first element encountered is the root element. This is a necessary declaration.

XML

could you please talk more specifically? :joy:

Again, no. It’s a long and windy road that needs some serious perusing of W3 pages, and all its internet accoutrements.

1 Like

Anyway. Thank you. I still have a lot to learn :smile:

1 Like

Please do let us know anything more that you discover. We’re all ears. Keep digging!

1 Like