Every HTML document starts the same way: **`<!DOCTYPE html>`** tells the browser to render in standards mode (not quirks mode, a legacy compatibility mode from the 1990s). The **`<html>`** element is the root of the whole document. Inside it, **`<head>`** holds metadata (title, links, scripts) that isn't shown directly, and **`<body>`** holds everything the user actually sees.
1Understanding Hello World!
Every HTML document starts the same way: `<!DOCTYPE html>` tells the browser to render in standards mode (not quirks mode, a legacy compatibility mode from the 1990s). The `<html>` element is the root of the whole document. Inside it, `<head>` holds metadata (title, links, scripts) that isn't shown directly, and `<body>` holds everything the user actually sees.
You almost never need to write <!DOCTYPE html> by hand today — every code editor and framework scaffolds it for you — but knowing what it does explains why old sites sometimes render in a broken 'quirks mode' layout.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first web page.</p>
</body>
</html>2Practical Example
Here is a real-world application of Hello World! showing how it is used in production HTML.
<!-- Without a doctype, old browsers can fall back to 'quirks mode' -->
<!-- Always declare it explicitly: -->
<!DOCTYPE html>
<html lang="en">
<!-- ... -->
</html>3Best Practices
Follow these guidelines when working with Hello World!:
1. Always start a document with <!DOCTYPE html>
2. Set the language with <html lang="en"> for accessibility and SEO
3. Keep the <body> focused on content — metadata belongs in <head>
Tip: You almost never need to write <!DOCTYPE html> by hand today — every code editor and framework scaffolds it for you — but knowing what it does explains why old sites sometimes render in a broken 'quirks mode' layout.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first web page.</p>
</body>
</html>