Complete HTML Handbook
Beginner to Advanced — Tags, Forms, SEO, Accessibility & Interview Prep
HTML (HyperText Markup Language) is the standard markup language for documents displayed in web browsers. It describes structure and meaning — not visual design (that is CSS) or behavior (JavaScript).
<p>HTML marks up <strong>content</strong> so browsers know what each part means.</p>Output: Paragraph with bold emphasis on the word "content".
Tim Berners-Lee created HTML in 1991 at CERN. The IETF published HTML 2.0 in 1995; W3C standardized HTML 3.2 and 4.01. WHATWG and W3C later unified on HTML5 (2014), adding semantic elements, native media, and APIs.
<!-- HTML5 document -->
<!DOCTYPE html>
<html lang="en">...</html>Output: Standards-mode rendering in modern browsers.
Early HTML (1–3) was informal. HTML 4.01 split Strict, Transitional, and Frameset. XHTML 1.0 enforced XML rules. HTML5 is the living standard: semantic tags, <video>, <canvas>, form types, and Web Components.
<!DOCTYPE html>
<!-- HTML5 — no version number in DOCTYPE -->Output: Standards mode in all current browsers.
Browsers parse HTML into a DOM tree, fetch linked resources (CSS, JS, images), build the CSSOM, run layout (reflow), paint, and composite layers. Parser errors are often auto-corrected — valid markup still matters for accessibility and SEO.
<link rel="stylesheet" href="styles.css">
<script src="app.js" defer></script>Output: Styled, interactive page after parse + resource load.
Every HTML document has <!DOCTYPE html>, an <html> root, <head> for metadata, and <body> for visible content. Optional but recommended: lang on <html>, charset meta, viewport meta.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Site</title>
</head>
<body>
<main>...</main>
</body>
</html>Output: Valid, responsive, accessible document shell.
The DOCTYPE triggers standards mode. HTML5 uses the short form <!DOCTYPE html> with no public identifier.
<!DOCTYPE html>Output: Browser uses HTML5 parsing rules.
<head> holds machine-readable metadata; <body> holds content users see. Scripts may go in either — prefer defer at end of body or in head with defer.
<head><title>Product</title><meta name="description" content="..."></head>
<body><h1>Product</h1></body>Output: Title in tab; description for search snippets; visible heading.
Elements use opening/closing tags (or void self-closing form). Attributes are name="value". Nesting must respect content models. IDs must be unique; classes may repeat.
<ul>
<li>Item</li>
</ul>Output: Bulleted list with one item.
Comments use <!-- ... --> and are ignored by the parser. Do not put secrets in comments — they ship to clients.
<!-- Navigation start -->
<nav>...</nav>
<!-- Navigation end -->Output: Nav renders; comments invisible.
Use semantic elements, one h1 per page, meaningful alt text, labels on inputs, valid nesting, progressive enhancement, and validate with W3C validator. Separate structure (HTML), presentation (CSS), behavior (JS).
<main>
<article>
<h1>Post title</h1>
<p>...</p>
</article>
</main>Output: Clear document outline for users and crawlers.