CHAPTER 04 · HTML

Create, save, open and update your first HTML page

Now you will build a small page from start to finish. The goal is not to decorate it. The goal is to know where the file is, understand its message and prove that your saved changes appear in the browser.

Download example files (ZIP)

What you will learn

  • Create a complete HTML document in your practice folder.
  • Understand every line at a first-reading level.
  • Recognise the difference between a browser tab title and a page heading.
  • Make one controlled change and check the result.
  • Find common file, saving and punctuation mistakes.

The problem: a campus repair desk notice

Your college is holding a small help session where students can get advice about basic computer problems. The organiser needs a page that explains the session name, location and what to bring.

We will make a simple notice. It will not book appointments or save personal details. Those requirements would need more work than displaying a message.

Step 1: create the file

Open the html-practice folder you made in Chapter 3. Create a new plain text file and save it as repair-desk.html. Do not put the HTML into a Word document. If the filename is hidden, show extensions and check that the final name is not repair-desk.html.txt.

The name helps you identify the page. It is not a special HTML command. We use a meaningful name because several files called new1 and new2 would be difficult to recognise later.

Step 2: write the complete page

Type the example slowly, or use Copy and paste it into the editor. If you paste, still read it line by line. The blank space at the start of some lines makes the structure easier to read; it is called indentation.

repair-desk.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Campus Repair Desk Notice</title>
</head>
<body>
  <h1>Campus repair desk</h1>
  <p>Visit Room 12 on Wednesday at 2 pm.</p>
  <p>Bring your laptop and its charger.</p>
</body>
</html>
Browser previewDocument title: Campus Repair Desk Notice

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

Read each line without rushing

<!DOCTYPE html> is a declaration. A declaration provides information about how to read the document. This form tells the browser to use its normal standards mode for an HTML document. It is not a heading and is not printed as page text.

<html lang="en"> begins the element that holds the document. The language attribute identifies English as the main language. </html> ends this outer element.

<head> begins the section containing information about the document. It includes the character encoding and the page title in this example. </head> ends that section.

<meta charset="UTF-8"> identifies the character encoding. Keep the saved file in UTF-8 too. There is no </meta> closing tag in HTML. You will study this kind of element in Chapter 6.

<title>Campus Repair Desk Notice</title> gives the document its title. It normally appears in the browser tab and helps identify a bookmarked page. It is not the main visible heading in the body.

<body> begins the document's main content. The heading and paragraphs in this example belong here. </body> ends that section.

<h1>Campus repair desk</h1> describes the main heading. Use it for its meaning, not simply to request a particular font size. The browser supplies a starting appearance.

Each <p>...</p> element describes a paragraph. Here, one paragraph gives the location and time; the other explains what students should bring.

The angled brackets < and > form the tag boundaries. The slash / in a closing tag marks an ending. Keep these characters distinct: a backslash \ is a different character.

Step 3: save and open it

Save the file from the editor. Then open it with your browser through the file manager's Open with option, or the browser's Open File command. If you double-click and it opens in the editor, choose the browser explicitly.

You should see a heading and two paragraphs, matching the preview above. In a normal tab, you should also see Campus Repair Desk Notice. Your text sizes may look slightly different from someone else's because default fonts and browser settings vary.

The page itself should not print <h1> or </p>. If you see tags as literal text, check whether you opened a plain text copy or whether the source was escaped or saved as a different format.

Step 4: update one detail

The organiser changes the room from 12 to 18. Find the location paragraph and change only the room number. Save the file and refresh the browser.

HTML fragment — part of a document
<p>Visit Room 18 on Wednesday at 2 pm.</p>

This fragment replaces one paragraph inside the full document. Do not replace the entire file with it if you want to keep the complete structure.

Your browser should now show Room 18. That is your first small test: you made one change, predicted its effect and checked the saved result.

Change one detail and prove it
  1. 1Predict: room should become 18
  2. 2Edit only the room number
  3. 3Save and refresh
  4. 4Check the displayed paragraph

A useful test has an expected result. Seeing something on the screen is not enough to prove it is the intended result.

Step 5: change the tab title separately

Change only the text inside title to Repair Desk - Updated Room. Save and refresh. The tab title should change, but the body heading should remain Campus repair desk.

This is a useful test because beginners often expect title to print at the top of the body. The document title and visible heading serve related but different purposes.

ChangeWhere you should notice it
Text inside titleNormal browser tab or document title
Text inside h1Main heading in the page body
Text inside the first pLocation and time paragraph
Indentation before tagsSource readability; usually not a matching visible indentation

A second complete example: a student goal card

Try this in a separate file called learning-goal.html. Keeping it separate prevents the notice from being overwritten.

learning-goal.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My Weekly Learning Goal</title>
</head>
<body>
  <h1>My goal for this week</h1>
  <p>I will build and check three small HTML pages.</p>
  <p>I will explain each page before adding decoration.</p>
</body>
</html>
Browser previewDocument title: My Weekly Learning Goal

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

The complete file uses the same structure as the notice. Its content is different because it solves a different communication problem. Reusing a clear structure does not mean every page needs the same title or wording.

Problem and solution: check whether the result is right

Problem: the page appears, so a student assumes that it must be correct.

Solution: compare it with specific expectations. Does the tab have the intended title? Is the heading correct? Are both paragraphs present? Does the location match the latest instruction? Did the file keep its complete structure?

A browser can sometimes recover from missing or misplaced tags. That is helpful for visitors, but it is not proof that the source follows HTML rules. We will learn validation later. For now, compare carefully with the intended structure and keep your closing tags clear.

Common mistakes and useful tips

  • Changing text without saving: refresh cannot read an unsaved edit.
  • Saving in a different folder: compare the address bar with the editor's file location.
  • Changing title when you meant the visible heading: choose the part that serves the intended job.
  • Typing </p without >: check the boundaries of each tag.
  • Replacing / with \ in a closing tag: they are different characters.
  • Adding a semicolon after every HTML line because another language uses them: HTML tags do not require that.
  • Fixing several things at once: make one small change so that you can understand its result.

Practice questions

  1. Create repair-desk.html in your practice folder and open it in a browser.
  2. Change the day to Friday and verify that the page shows the saved change.
  3. Change only the document title. What should remain unchanged in the body?
  4. Explain what the slash does in </body>.
  5. Find and repair the problem in </p.
  6. Create a separate notice for a lost notebook using a meaningful title, one heading and two paragraphs. Use fictional contact details or no personal contact information.
Check your practice answers
  1. The browser should show the heading and both paragraphs. Check the full filename and location if it opens as text or shows an old copy.
  2. Edit the time paragraph, save, then refresh. It should say Friday while the remaining text stays as intended.
  3. The main heading and paragraphs should stay unchanged because they are separate from the title element.
  4. It marks the tag as a closing tag, ending the body element.
  5. Add the missing closing angle bracket to make </p>.
  6. Use the same complete document structure, but write your own notice content. For example, the title can be Lost Notebook Notice, the heading Found a notebook, and the paragraphs can describe the cover and the college desk where it can be collected.

Interview questions

How do you view a plain HTML file locally?

Save it as a plain text .html file, then open it in a browser. After editing, save and reload to check the new version. These examples need no separate compile step.

How do title and h1 differ?

The title names the document and normally appears in the tab. An h1 identifies a main heading within the body. They may use similar words but are separate elements.

What is indentation for in these examples?

It helps a person read which parts are inside other parts. It is not a replacement for CSS spacing, and source indentation usually does not become the same visible spacing in ordinary page text.

What checks would you do if a saved edit did not appear?

Confirm Save, refresh the browser, compare the full file location and reopen the intended copy. Check small causes before changing tools or rewriting the whole page.

Quick revision

  • A complete document has a clear outer structure and meaningful content.
  • Save source as plain HTML, then open it in the browser.
  • The document title and body heading have different jobs.
  • Predict, change, save, refresh and compare.
  • Visible output does not prove that all HTML rules were followed.
  • Keep separate practice tasks in clearly named files.