Open any web page's source code and you'll find the same skeleton at the top, before a single word of visible content appears. That skeleton — the boilerplate — isn't decoration. Each line tells the browser something it needs to know before it can render the page correctly.

The minimum every page needs

TagWhat it does
<!DOCTYPE html>Tells the browser to use modern HTML5 rendering rules
<html lang="en">Wraps the whole page; the language attribute helps screen readers and translators
<head>Holds metadata that isn't displayed directly — title, character set, viewport
<meta charset="UTF-8">Sets the character encoding so accents, emoji and symbols render correctly
<meta name="viewport">Controls how the page scales on mobile devices
<title>Sets the browser tab title and the default search-result headline
<body>Holds everything the visitor actually sees

Why the DOCTYPE isn't optional

Without a <!DOCTYPE html> declaration, older browsers fall back to quirks mode — a compatibility mode that mimics the inconsistent rendering behavior of browsers from the late 1990s. Quirks mode changes how box sizing, margins and even basic layout are calculated, which causes CSS to behave unpredictably. A single line at the top of the file avoids all of it.

The viewport meta tag — the difference between mobile-friendly and broken

Without <meta name="viewport" content="width=device-width, initial-scale=1.0">, mobile browsers assume your page was built for a desktop screen and render it at roughly 980px wide, then zoom out to fit — leaving visitors pinching and zooming to read anything. This single tag tells the browser to match the page width to the actual device width instead.

Forgetting the viewport tag is one of the most common reasons a page looks fine on a laptop but broken on a phone.

Common beginner mistakes

Why a live preview speeds up learning

The traditional edit-save-refresh-switch-tabs loop breaks concentration every time — by the moment you see the result, you've half-forgotten which line you changed. A live preview closes that gap to zero: type a tag, see it render immediately, and the connection between markup and result stays intact. Testing at different device widths (desktop, tablet, mobile) in the same view also makes responsive-design mistakes obvious the moment they happen, instead of after publishing.

Build the habit of checking mobile width first. More web traffic arrives on phones than desktops, so a page that looks right at 375px wide before you optimize for 1200px will save you rework later.

A minimal complete example

Putting it all together, the smallest complete, valid HTML page looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Page</title>
</head>
<body>
  <h1>Hello!</h1>
</body>
</html>

Every larger page — no matter how complex — builds outward from exactly this structure.