Frontend Master

JavaScript Curriculum

Your First Webpage
+35 XP

Your First Webpage

easy
~20 min·35 XP

You've just joined Nexus Engineering. Your first task: stand up the company's new internal portal. Before you write a single heading or button, you need to understand the skeleton every webpage is built on.

Your First Webpage

Every webpage you've ever visited — from Google to GitHub — starts with the same skeleton. Before browsers can render colors, layouts, or animations, they need to know the rules of the document they're reading. That's what the HTML boilerplate provides.

ℹ️What is HTML?
HTML stands for HyperText Markup Language. It's not a programming language — it has no logic, no loops, no conditions. It's a description language: you describe the structure and meaning of content, and the browser figures out how to display it.

The Complete Boilerplate

html
<!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> <!-- Your content here --> </body> </html>

Step through each part of this structure — every line has a specific job:

index.html
1 / 7
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>My First Webpage</title>
7 <link rel="stylesheet" href="styles.css">
8 </head>
9 <body>
10 <h1>Hello, World!</h1>
11 </body>
12</html>
<!DOCTYPE html>Required

Document Type Declaration

Not an HTML tag — it's a browser instruction. It switches the browser into standards mode rather than legacy "quirks mode". Without it, your CSS layout will behave inconsistently across browsers.

💡 Pro tip

Always the very first line. Even a blank line before it can trigger quirks mode in older browsers.

Anatomy of an HTML Tag

HTML is built from elements, and elements are defined by tags. Understanding tag anatomy makes every lesson that follows easier:

tag-anatomy.html

Click any tag name, attribute, value, or content to learn what it does

<a href="https://example.com" target="_blank">Visit Site</a>

← Click a coloured part of the tag to learn what it does

💡Void Elements
Some elements don't wrap content — they stand alone. These are called **void elements** and don't need a closing tag: `<meta>`, `<link>`, `<img>`, `<br>`, `<input>`. Writing `<meta />` is valid but the slash is optional in HTML5.

How the Browser Sees Your File

When you save an HTML file and open it in a browser, it goes through three distinct stages before you see anything on screen:

index.html

Raw bytes the server sends — the browser downloads and parses this file

1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>My First Webpage</title>
7 <link rel="stylesheet" href="styles.css">
8 </head>
9 <body>
10 <h1>Hello, World!</h1>
11 </body>
12</html>

Why the DOCTYPE Matters

Before HTML5, there were competing browser rendering modes. Without <!DOCTYPE html>, browsers enter quirks mode — a compatibility mode that mimics old, broken browser behaviour. Your carefully written CSS will render differently across browsers. Always start with the DOCTYPE.

⚠️Common Mistake — Whitespace Before DOCTYPE
The DOCTYPE must be the absolute first thing in your file. Even a single blank line before it triggers quirks mode in some browsers. No exceptions.

The lang Attribute

The lang="en" attribute on the root <html> element tells:

  • Screen readers which language to use for pronunciation
  • Search engines the primary language of the content
  • Translation tools the source language

For a French page, use lang="fr". For a bilingual page, you can override it on specific elements: <p lang="fr">Bonjour</p>.

Challenge

Build a valid HTML5 boilerplate from scratch. Your page must include a DOCTYPE, a root html element with a lang attribute, a head with charset and viewport meta tags plus a meaningful title, and a body with a single h1 greeting.

htmlboilerplatedoctypeheadbodymeta
Your First Webpage | Nexus Learn