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
Step 1: create the file
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.
Step 2: write the complete page
<!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>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.
<p>...</p> element describes a paragraph. Here, one paragraph gives the location and time; the other explains what students should bring.
< 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
<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
<p>Visit Room 18 on Wednesday at 2 pm.</p>- 1Predict: room should become 18
- 2Edit only the room number
- 3Save and refresh
- 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
title to Repair Desk - Updated Room. Save and refresh. The tab title should change, but the body heading should remain Campus repair desk.
title to print at the top of the body. The document title and visible heading serve related but different purposes.
title | |
h1 | |
p | |
A second complete example: a student goal card
learning-goal.html. Keeping it separate prevents the notice from being overwritten.
<!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>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.
Problem and solution: check whether the result is right
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 titlewhen you meant the visible heading: choose the part that serves the intended job.Typing </pwithout>: 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
Create repair-desk.htmlin your practice folder and open it in a browser.Change the day to Friday and verify that the page shows the saved change. Change only the document title. What should remain unchanged in the body? Explain what the slash does in </body>.Find and repair the problem in </p.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
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. Edit the time paragraph, save, then refresh. It should say Friday while the remaining text stays as intended. The main heading and paragraphs should stay unchanged because they are separate from the title element. It marks the tag as a closing tag, ending the body element. Add the missing closing angle bracket to make </p>.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?
.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?
What is indentation for in these examples?
What checks would you do if a saved edit did not appear?
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.