The time has come to bring together everything you've learnt and create the first real page of the project: The Blue Cup's index.html. This lesson doesn't introduce any new syntax; it's about practising the complete workflow that you will repeat thousands of times as a developer: create the file, write the structure, add content, save, view it in the browser, inspect it with DevTools, make changes and reload. At the end you will have the complete document explained line by line.
Contents
- What you are going to build
- Step 1: create the
index.htmlfile - Step 2: write the document structure
- Step 3: add the tab title
- Step 4: add the heading and the welcome paragraphs
- Step 5: save and open in the browser
- Step 6: inspect with DevTools
- Step 7: make changes and reload
- The final document explained line by line
What you are going to build
When you finish, your project folder will look like this:
And the page will display:
- In the browser tab: Home | The Blue Cup.
- A main heading: The Blue Cup.
- Two welcome paragraphs introducing the café and its opening hours.
It's a simple page, but it is complete and correct: it follows all the structural rules you have studied. From here on, the remaining modules will gradually enrich it.
flowchart LR
A[Create file] --> B[Write HTML]
B --> C[Save]
C --> D[View in browser]
D --> E[Inspect with DevTools]
E --> F{Is it right?}
F -- No --> B
F -- Yes --> G[Next change]
G --> B
This edit → save → view → review cycle is the day-to-day reality of web development. The shorter it is (which is why we use Live Server), the faster you will learn.
Step 1: create the index.html file
- Open VS Code and open the project folder:
File > Open Folder…>the-blue-cup. - In the Explorer panel (left side bar), hover over the folder name and click the New File icon (a sheet of paper with a
+). - Type the name
index.htmland pressEnter.
Important details:
- The name is
index.html, all in lower case. This name has a special meaning for web servers, which you will see in File Organisation and Paths. - The
.htmlextension is what tells the system and the browser that this is an HTML document. (There is also.htm, an old variant; always use.html.) - Notice that the file icon in VS Code changes once it recognises the extension, and
HTMLappears as the language in the status bar at the bottom.
If you created test.html in the exercise in the lesson Setting Up Your Work Environment, you can delete it now (right-click > Delete).
Step 2: write the document structure
With index.html open and empty, write the basic structure. You can use the Emmet shortcut (! + Tab) and correct whatever is needed, but we recommend typing it by hand this first time: that way each part will stick in your memory.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
</body>
</html>Mentally review what you learnt in Basic Structure of an HTML Document:
- The doctype on the first line, to trigger standards mode.
htmlas the root, withlang="en"because the content is in English.headwith the UTF-8 encoding as its first element and themeta viewport(explained in Module 9).body, still empty.
If you used Emmet, check two things: that lang="en" is present (Emmet's default, and correct for this page) and that Emmet adds a title with the text Document, which you are going to change in the next step.
Step 3: add the tab title
Inside head, after the meta elements, add the title:
Why this text?
- "Home" comes first because it is the part specific to this page. When the user has several tabs from the site open, they will see the beginning of the title.
- "The Blue Cup" goes at the end as the site name. The other pages will follow the same pattern:
Menu | The Blue Cup,Bookings | The Blue Cup… - The vertical bar
|is just a common separator; dashes (–) are also used.
Step 4: add the heading and the welcome paragraphs
Now, inside body, add the visible content:
<h1>The Blue Cup</h1>
<p>Welcome to The Blue Cup, your neighbourhood café and bakery. We roast speciality coffee and every morning we bake bread, croissants and sponge cakes in our own bakery.</p>
<p>We look forward to seeing you every day from 8:00 to 20:00 at 12 Example Street, Fictional Town.</p>h1is the page's main heading. Normally there is one per page and it describes the page's main content; here, the name of the café.- Each
pis a paragraph. We have used two because they deal with different ideas: what the café is, and when and where to find it.
Don't worry yet about the different heading levels or how to highlight the opening hours: you will work on those in Module 2 (Headings and Paragraphs and Text Formatting Tags).
Remember about whitespace: long paragraphs can take up a single line in the editor or several; the browser will display them the same way. If you'd like the editor to wrap long lines visually without changing the file, enable
View > Word Wrap(Alt+Z).
Step 5: save and open in the browser
- Save with
Ctrl+S(Cmd+Son macOS). The dot on the editor tab disappears once the file is saved. - Open the page in one of these ways:
- Live Server: the Go Live button in the status bar, or right-click
index.html> Open with Live Server. - Double-click
index.htmlin your system's file explorer.
- Live Server: the Go Live button in the status bar, or right-click
You should see:
- In the tab: "Home | The Blue Cup".
- Large bold text: "The Blue Cup".
- Two paragraphs of normal text, separated by some vertical space.
It looks plain (serif typeface, white background, black text) because these are the browser's default styles. That's normal: there is no CSS yet. Notice too that the "é" in "café" displays correctly: that's thanks to <meta charset="utf-8">.
If something doesn't look right
| Symptom | Likely cause | Solution |
|---|---|---|
| The HTML code is displayed as text | The file is called index.html.txt or index.txt |
Rename it to index.html and turn on file extensions in your file explorer |
Strange characters (é) instead of accented letters |
meta charset is missing or the file isn't in UTF-8 |
Check the head and the encoding in VS Code's status bar |
The tab shows index.html or Document |
The title is missing or you didn't change it |
Add or correct the title inside head |
| Changes don't appear | You didn't save or didn't reload | Ctrl+S and, if you're not using Live Server, F5 |
| All the text is large | The closing </h1> is missing |
Close the heading before the first <p> |
Step 6: inspect with DevTools
Now examine your own page as you learnt in Setting Up Your Work Environment:
- Right-click the heading "The Blue Cup" > Inspect.
- The Elements panel will open with the
h1selected. Look at the tree:htmlcontainsheadandbody;bodycontainsh1and twopelements. - Expand
headwith the triangle: you will see the twometaelements and thetitle. - Hover over each
pin the panel: the corresponding paragraph is highlighted on the page, together with the space around it. - Press
Ctrl+Uto view the source code: it is exactly what you typed, with your indentation.
A useful experiment: temporarily delete the </h1> in the editor, save and go back to the Elements panel. You will see that the browser has "repaired" the document in its own way (usually closing the h1 in an unexpected place or putting the paragraphs inside it). Compare it with the source code, which shows the error as it is. Afterwards, restore the </h1> and save.
Step 7: make changes and reload
The last step of the cycle is to iterate. Make these changes one at a time, saving and watching the browser after each one:
- Add the sentence "You can also call us on +34 900 000 000." to the end of the second paragraph.
- Add a third paragraph with the text: "Email us at [email protected] and we'll get back to you as soon as possible."
- Add a comment just before the
h1:<!-- Welcome: home page -->. Check that it doesn't appear on the page but does appear in the source code.
With Live Server, each Ctrl+S updates the page automatically. Without it, remember to reload with F5. If the browser ever seems to be showing an old version, force a reload with Ctrl+F5 (Cmd+Shift+R on macOS), which bypasses the cache.
The final document explained line by line
This is the complete index.html after the steps above. Type it out or compare it with yours:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home | The Blue Cup</title>
</head>
<body>
<!-- Welcome: home page -->
<h1>The Blue Cup</h1>
<p>Welcome to The Blue Cup, your neighbourhood café and bakery. We roast speciality coffee and every morning we bake bread, croissants and sponge cakes in our own bakery.</p>
<p>We look forward to seeing you every day from 8:00 to 20:00 at 12 Example Street, Fictional Town. You can also call us on +34 900 000 000.</p>
<p>Email us at [email protected] and we'll get back to you as soon as possible.</p>
</body>
</html>| Line | Code | Explanation |
|---|---|---|
| 1 | <!DOCTYPE html> |
Declares a modern HTML document and triggers standards mode |
| 2 | <html lang="en"> |
Opens the root element and states that the content is in English |
| 3 | <head> |
Opens the metadata section (nothing here is visible on the page) |
| 4 | <meta charset="utf-8"> |
UTF-8 encoding: accented letters, € and £ display correctly |
| 5 | <meta name="viewport" …> |
Adapting to mobile screens (Module 9) |
| 6 | <title>Home | The Blue Cup</title> |
Text for the tab, bookmarks and search engine results |
| 7 | </head> |
Closes the head |
| 8 | <body> |
Opens the body: the visible content begins |
| 9 | <!-- … --> |
Comment for whoever reads the code; the browser ignores it |
| 10 | <h1>The Blue Cup</h1> |
The page's main heading |
| 11 | <p>Welcome…</p> |
First paragraph: what the café is |
| 12 | <p>We look forward…</p> |
Second paragraph: opening hours, address and phone number |
| 13 | <p>Email us…</p> |
Third paragraph: contact email |
| 14 | </body> |
Closes the body |
| 15 | </html> |
Closes the root element: end of the document |
Notice that the phone number and the email address are, for now, plain text. In Module 3 (Special Links: Anchors, Email, Phone and Downloads) you will turn them into links that open the phone app or the email program.
Common Mistakes and Tips
- Working on a file outside the project folder: check in the VS Code explorer that
index.htmlsits directly insidethe-blue-cup/. - Writing content outside
body: everything visible goes between<body>and</body>. If you write text after</html>, the browser will still display it, but it's an error. - Several
h1elements "to make it look big": theh1is the main heading, not a sizing tool. Size is controlled with CSS. - Using
Enterto separate paragraphs: line breaks in the code aren't visible; each paragraph needs its ownpelement. - Editing in DevTools and closing the browser: the changes are lost. The file in your editor is the single source of truth.
- Tip: save often and check the result after each small change. If you make ten changes before looking and something breaks, it will be harder to find the error.
Exercises
Exercise 1. A standalone test page. Without looking at the lesson, create a file opening-hours.html outside the project with a complete structure, the title "Opening Hours | The Blue Cup", an h1 with the text "Opening Hours" and two paragraphs: one for Monday to Friday (8:00 to 20:00) and another for weekends (9:00 to 14:00). Open it in the browser and check it with DevTools.
Exercise 2. Diagnose the problem. A colleague sends you this index.html and says that "the tab says index.html, the accented letters come out wrong and all the text is huge". Find the causes.
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<title>Home | The Blue Cup</title>
<h1>The Blue Cup
<p>Speciality coffee and handmade pastries at our café.</p>
</body>
</html>Exercise 3. Extend your index.html. Add a paragraph to the home page, before the email one, introducing the coffee of the week (make up the name and origin) and use a title attribute on it with some supplementary information. Check the tooltip in the browser.
Solutions
Solution 1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Opening Hours | The Blue Cup</title>
</head>
<body>
<h1>Opening Hours</h1>
<p>Monday to Friday, from 8:00 to 20:00.</p>
<p>Saturdays and Sundays, from 9:00 to 14:00.</p>
</body>
</html>If you wrote it from memory without errors, you have internalised the structure. If you forgot the charset or the lang, go back over Basic Structure of an HTML Document.
Solution 2.
- "The tab says index.html": the
titleis insidebodyinstead ofhead. (The browser may move it, but it isn't correct; move it tohead.) - "The accented letters come out wrong":
<meta charset="utf-8">is missing fromhead. - "All the text is huge": the
h1isn't closed, so the paragraph ends up inside the heading. A</h1>is missing after "The Blue Cup". - In addition, the
meta viewportis missing.
Solution 3. One possible solution (the paragraph goes between the opening hours one and the email one):
<p title="Medium roast, notes of chocolate and orange">This week we recommend our Colombian coffee, ideal black or with milk.</p>When you hover over the paragraph, a box will appear with the roast information. Remember that title shouldn't contain essential information, since it can't be seen on mobile devices.
Conclusion
You have created the first real page of the project: the-blue-cup/index.html, with its complete structure, a descriptive title, the main heading and several welcome paragraphs. Above all, you have practised the working cycle of any web developer: edit, save, view in the browser, inspect with DevTools and correct. Right now the project is a single file; but a real website has several pages, stylesheets, images and videos. In the next lesson, File Organisation and Paths, you will set up The Blue Cup's folder structure and learn to write the paths that connect files to one another.
HTML Course
Module 1: Introduction to HTML
- What Is HTML?
- Setting Up Your Work Environment
- Basic Structure of an HTML Document
- Tags, Elements and Attributes
- Creating Your First HTML Page
- File Organisation and Paths
Module 2: Text Formatting in HTML
- Headings and Paragraphs
- Text Formatting Tags
- Lists: Ordered, Unordered and Description Lists
- Block Quotes and Preformatted Text
- Block and Inline Elements: div and span
Module 3: Links and Media in HTML
- Creating Hyperlinks
- Special Links: Anchors, Email, Phone and Downloads
- Adding Images
- Embedding Videos
- Using the Audio Element
Module 4: Tables in HTML
- Basic Table Structure
- Table Head, Body and Foot
- Merging Cells: colspan and rowspan
- Accessible Tables: caption, scope and headers
- Styling Tables
Module 5: Forms in HTML
- Creating a Basic Form
- Form Elements: input, textarea and select
- HTML5 Input Types
- Labels and Grouping: label, fieldset, legend and datalist
- Form Attributes and Validation
- Submitting Forms
Module 6: HTML5 Semantic Elements
- Introduction to Semantic HTML
- header, nav and footer
- article, section and aside
- main and figure
- Other Semantic Elements: time, address, details and dialog
Module 7: Advanced HTML Techniques
- HTML Entities
- Using iframes
- Data Attributes
- Metadata: meta, SEO and Open Graph
- Microdata and Structured Data
- Graphics in HTML: SVG and canvas
Module 8: Integrating HTML and CSS
- Linking CSS to HTML
- Inline, Internal and External CSS
- Basic CSS Selectors
- The Box Model
- Styling HTML Elements
- Introduction to Layout with Flexbox and Grid
Module 9: Responsive Web Design
Module 10: Best Practices and Accessibility
- HTML Best Practices
- Validating HTML Code
- Web Accessibility Basics
- Using ARIA Roles and Attributes
- Accessibility Testing
- Performance and Resource Loading
