When writing an HTML document, the first line is usually: <!DOCTYPE html>
This line is called the DOCTYPE declaration, and the exclamation mark (!) plays an important role in its meaning.
What the Exclamation Mark (!) Represents
In HTML, the exclamation mark indicates that the content is a declaration, not a normal HTML element.Normal HTML elements use tags like <html>, <head>, and <body>Declarations use <! ... >The ! tells the browser:“This is special instruction for the browser, not content to be displayed.”
So, <!DOCTYPE html> is not an HTML tag — it is a browser instruction.Purpose of <!DOCTYPE html>
The DOCTYPE declaration tells the browser:Which version of HTML the document is written inHow the browser should interpret and render the pageWhen we write:<!DOCTYPE html>It tells the browser to use HTML5 standards mode.
Without the exclamation mark:The browser might treat the document incorrectlyIt may enter quirks mode, which can cause layout and styling issuesModern HTML features may not work properly
The ! ensures the browser understands that this line is a mandatory declaration, not a regular tag.