In SGML, which is what HTML was nominally based on, up to and including HTML 4.01, the exclamation mark is part of the construct <!
, which is the reference concrete syntax for mdo, markup declaration open. Markup declarations are not markup elements but, informally speaking, declarations relating to elements. This includes document type declaration, comment declarations, and entity declarations.
In XML, which is what XHTML is based on, there is no general concept like that. Instead, the character pair <!
just appears in some constructs, with no uniform theory.
In HTML5, the HTML syntax has been defined very much in an ad hoc manner, and the doctype string is called just the doctype string – it has no role and no meaning beyond the expected effect of triggering “standards mode” (or “no-quirks mode”) in browsers. In the XHTML syntax, it has its XML meaning.
<!
shows how each<!
grammar case is defined one by one. Of course, the underlying idea of all of them is: "this is a magic instruction for the parser, not part of your regular data." – Bennie