Skip to content Skip to sidebar Skip to footer

Why Is The -tag Not Closed

It's a general quuestion, and none of my profs could answer it: Why do I not have to close the -Tag in HTML? Every other tag has to be closed, like <

Solution 1:

First of all, it’s not a tag at all. In HTML versions nominally based on SGML or XML, it’s a document type declaration, which has a specific syntax defined in SGML and XML. Being a declaration about the document as a whole, it’s nothing like HTML elements, and it precedes the elements. In HTML5 in HTML syntax, it’s just a required string with no defined role. (In practice, it puts browsers to “standards mode” as opposite to “quirks mode”. Browsers do not actually read the document type definition that the declaration points to. Validators may do that.)

The relevant references are the SGML standard (not available online), the XML specification, and the HTML5 CR.

The formulation of the statement “Every other tag has to be closed” in the question is misleading in other ways, too. Closing a tag (like <p>) and closing an element (like <p>foo</p>) are two different things. The > closes a tag. Elements do not always need explicit end tags, since the end can be inferred by various rules; only XHTML requires explicit end tags for all elements (if we count a “self-closing” tag like <br/> as both a start tag and an end tag, as it is). But for this doctype thing, no end needs to be indicated or inferred, except the ending > of the declaration.

Solution 2:

Because it is NOT a tag, it's a declaration.

http://www.w3schools.com/tags/tag_doctype.asp

Solution 3:

The declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.

Source: http://www.w3schools.com/tags/tag_doctype.asp

Is this your answer?

Post a Comment for "Why Is The -tag Not Closed"