Programming

How do I write my first HTML page?

The page skeleton, saving the file and opening it in a browser.

All lessons · HTML lessons: learn from scratch

The page skeleton

Every HTML page starts with the same skeleton. Put this into a file named index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>My first page</title>
  </head>
  <body>
    <h1>Hello!</h1>
    <p>This is my first web page.</p>
  </body>
</html>

How to open it

  1. Save the file as UTF-8 (the default in VS Code).
  2. Double-click the file — it opens in your browser.
  3. After editing, save and refresh the page (F5).

Key idea: <head> holds information about the page, <body> holds what is shown on screen.

Author: Nibras Code