Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does exclamation point stand for in HTML in constructs like DOCTYPE and comments?

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

Why the exclamation point? What is it called, what does it mean/do?

I have read through the HTML syntax spec and found no real explanation other than

Any case-insensitive match for the string <!DOCTYPE.

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

like image 546
superUntitled Avatar asked May 01 '13 15:05

superUntitled


People also ask

What is the exclamation mark used for in Javascript?

In Javascript, the exclamation mark (“!”) symbol, called a “bang,” is the logical “not” operator. Placed in front of a boolean value it will reverse the value, returning the opposite.

What is the style value of exclamation icon?

In computing, the exclamation mark is ASCII character 33 (21 in hexadecimal).

Why is there an before doctype?

It tells the browser that your code is html so it can understand it. It also tells what kind of html to expect (html4 or html5) or if it's xml etc. The use of the exclamation mark or point ( ! ) before DOCTYPE is a historical leftover from earlier versions of HTML.


2 Answers

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.

like image 197
Jukka K. Korpela Avatar answered Sep 27 '22 23:09

Jukka K. Korpela


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

like image 42
Shoe Avatar answered Sep 27 '22 22:09

Shoe