Loading...

HTML essentialsGetting Started

Setup & your first page

5 min lesson

Next
  • You need two things to start: a text editor to write HTML and a browser to view it.
  • A plain text editor like VS Code, Notepad++ or even Notepad works; do not use a word processor that adds formatting.
  • Save your file with the .html extension, for example first.html, so the browser knows it is a web page.
  • Open the file in your browser by double-clicking it or dragging it into a browser window.
  • The browser reads your HTML from top to bottom and displays the content it finds.
  • This builds on How the web works: browsers, HTTP & URLs; now you are the server, and the file is on your own computer.
  • The example writes a tiny page with a heading and a paragraph; you will see both in the browser.
Keep in mind
  • Use a plain text editor and save with the .html extension.
  • Open the file in a browser to see the result; refresh after each change.
  • Start with one heading and one paragraph, then grow.
  • If nothing shows, check the file name ends in .html and you saved it.
first.html
<!DOCTYPE html>
<html lang="en">
<head>
  <!-- The title appears in the browser tab -->
  <meta charset="UTF-8">
  <title>My first page</title>
</head>
<body>
  <!-- The biggest heading on the page -->
  <h1>Hello, web!</h1>
  <!-- A short paragraph of normal text -->
  <p>This is my first web page.</p>
</body>
</html>

What happens: A browser tab titled "My first page" and a page showing the heading "Hello, web!" and the paragraph "This is my first web page."

Breaking it down

Doctype

<!DOCTYPE html>

Tells the browser this is modern HTML. Without it, the browser may use an old mode and render things differently.

html element

<html lang="en">

Wraps the whole page and declares the language as English. It helps screen readers pronounce content correctly.

head

<head> ... </head>

Holds information about the page, like the title and character set. This content is not shown in the page body.

body

<body> ... </body>

Holds everything the user sees, like headings and paragraphs. Without it, your visible content has no proper home.

A helpful analogy

Writing HTML is like writing a letter. The editor is your pen, the .html file is the paper, and the browser is the reader who opens the envelope and reads it.

Nesting rules

  • 1.Always close a tag after you open it, and close the most recent one first.
  • 2.Keep head and body inside html, and keep visible content inside body.

Common mistakes

Saving the file with the wrong extension

Avoid

first.txt

Use instead

first.html

The browser uses the extension to know it is a web page. A .txt file may show raw code instead of a page.

Putting visible content outside body

Avoid

<h1>Hi</h1> before <body>

Use instead

<body><h1>Hi</h1></body>

Browsers may still show it, but the structure is wrong and tools like screen readers can get confused.

Quick tips

  • •Keep the editor and browser side by side and refresh after each small change.
  • •Use indentation of two spaces so the structure is easy to scan.
Previous
Next