On this page10 sections
  1. Learning Objectives
  2. 1. The Page Skeleton
  3. 2. Head vs Body
  4. 3. Indentation Makes It Readable
  5. 4. Making the File on Your Computer
  6. Code Examples
  7. Common Beginner Mistakes
  8. Practice Questions
  9. Practice Answers
  10. Key Takeaways

Lecture 002: Editors & Your First Web Page

Category1: Getting Started
Lecture002 of 048
Estimated video length10 min
TargetHTML5 · any modern browser
LevelBeginner

Every HTML page has the same skeleton: a few lines at the top that you'll type on every page you ever make. Learn them once, and you have a template for life.


Learning Objectives

  • Write the basic skeleton of an HTML page from memory
  • Explain what <!DOCTYPE html>, <html>, <head> and <body> do
  • Save an HTML file on your computer and open it in a browser

1. The Page Skeleton

Example

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>My First Page</title>
  </head>
  <body>
    <h1>Hello, web!</h1>
    <p>This is my first web page.</p>
  </body>
</html>

Here is what each line does:

LineMeaning
<!DOCTYPE html>"This is a modern HTML page." Always the very first line.
<html lang="en">Wraps the whole page. lang says the page is in English.
<head>Information about the page. Not shown on the page itself.
<meta charset="UTF-8">Lets the page show every language and emoji correctly.
<title>The text on the browser tab.
<body>Everything visible on the page goes here.

2. Head vs Body

A simple rule: if visitors should see it, put it in <body>.

The <head> holds settings: the title, the character set, and later links to CSS files.

Example: change the title and watch where it would appear:

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Shown on the tab, not the page</title>
  </head>
  <body>
    <p>Only this paragraph appears on the page.</p>
  </body>
</html>

3. Indentation Makes It Readable

Browsers ignore extra spaces and line breaks, so these two are the same page:

html
<body><h1>Hi</h1><p>Welcome.</p></body>
html
<body>
  <h1>Hi</h1>
  <p>Welcome.</p>
</body>

The second one is far easier to read. Indent anything that sits inside another tag by two spaces.


4. Making the File on Your Computer

  1. Open a text editor (VS Code, or even Notepad / TextEdit in plain-text mode).
  2. Paste the skeleton from section 1.
  3. Save it as index.html. The .html ending matters.
  4. Double-click the file. It opens in your browser.
  5. Edit the file, save it, and refresh the browser to see the change.

index.html is the usual name for a site's home page. Web servers open it automatically.


Code Examples

Example 1: A Personal Page

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Ali Khan</title>
  </head>
  <body>
    <h1>Ali Khan</h1>
    <p>Student, footballer and future web developer.</p>
    <p>Currently learning: HTML.</p>
  </body>
</html>

Common Beginner Mistakes

1. Putting content in <head>. A <p> inside <head> is in the wrong place. Visible content belongs in <body>.

2. Saving as index.html.txt. Some editors add .txt. Turn on "show file extensions" and make sure the file ends in .html.

3. Forgetting to refresh. The browser does not notice that you saved. Press refresh (F5 / ⌘R).

4. Two <body> tags. A page has exactly one <head> and one <body>.


Practice Questions

  1. What must the very first line of an HTML page be?
  2. Where does the text in <title> appear?
  3. You want a paragraph visitors can read. Does it go in <head> or <body>?
  4. Why add <meta charset="UTF-8">?
  5. What file name is normally used for a site's home page?
  6. Do extra spaces and blank lines change how the page looks?

Practice Answers

  1. <!DOCTYPE html>
  2. On the browser tab (and in bookmarks and search results).
  3. In <body>.
  4. So that every character, including other languages and emoji, displays correctly.
  5. index.html
  6. No. The browser collapses them, so use them freely to keep your code readable.

Key Takeaways

  • Every page: <!DOCTYPE html>, then <html> containing one <head> and one <body>.
  • <head> = settings and title; <body> = everything visitors see.
  • Indent nested tags so you can read your own code.
  • Save files with the .html ending and refresh the browser after each change.