What does the exclamation mark in HTML mean in constructs like DOCTYPE and comments?

I am curious about the syntax of doctype tags and comments ...

Why an exclamation mark? What is it called, what does it mean / do?

I read the HTML syntax specification and found no real explanation other than

Any case-insensitive string match <!DOCTYPE .

Cite: http://www.w3.org/TR/html-markup/syntax.html#doctype-syntax

+8
syntax html history
source share
4 answers

In SGML, on the basis of which nominal HTML was based, up to HTML 4.01, an exclamation mark is part of the <! , which is the referenced concrete syntax for mdo, the markup declaration is open. Markup declarations are not markup elements, but, informally, declarations related to the elements. This includes document type declarations, comment declarations, and entity declarations.

There is no such general concept in the XML that XHTML is based on. Instead, a pair of <! just appears in some constructions without a single theory.

In HTML5, the HTML syntax was defined in a very special way, and the doctype line is called only as the doctype line - it has no role and does not matter except the expected effect of launching the "standard mode" (or the "non-quirks" mode) in browsers . In XHTML syntax, it has its own XML meaning.

+17
source share

! used for comments ( <!-- --> ) and for defining a DOCTYPE HTML document ( <!DOCTYPE ...> ). DOCTYPE describes some characteristics of a document, such as the root of an XML / XHTML / HTML file (usually in HTML <html> ), DTD , Public Identifier, and other subset declarations.

+4
source share

From the HTML spec from Cern docs:

MDO

The Open markup declaration: "<!", Followed by either the letter "-" or "[", signals one of several SGML markup declarations. The only purpose it serves in HTML is to introduce comments.

Source: http://info.cern.ch/hypertext/WWW/MarkUp/Connolly/Text.html

+1
source share

A <!DOCTYPE ...> is an SGML document type declaration. Its purpose is to tell the SGML parser which DTD it should use to parse the document.

0
source share

All Articles