Our Code Editor โ Visual Studio Code
Before we write a single line, we need the right tool. Our choice is VS Code โ free, supports every programming language, and is one of the most widely used code editors in the world.
1What is a code editor and why do we need one?
Technically you can write HTML in Windows Notepad โ but that's like performing surgery with a hammer. It's possible, but much harder and more error-prone. A code editor helps prevent mistakes, lets you work faster, and makes it immediately clear what is what in the code.
Syntax highlighting โ HTML tags appear in red, JS keywords in purple, strings in green. The structure is visible at a glance.
Auto-completion โ start typing <div and it suggests the closing </div>.
Error highlighting โ red underlines show typos before you even try to run the code.
Find and replace โ finds and replaces every occurrence of a word across the entire project at once.
2Why VS Code โ a comparison
| Editor | Price | Languages | Extensibility | Learning curve |
|---|---|---|---|---|
| VS Code โ | Free | 100+ | Thousands of extensions | Medium โ 1โ2 days |
| Notepad++ | Free | Many | Limited | Very easy |
| Sublime Text | ~$80 | Many | Medium | Easy |
| WebStorm | ~$70/year | Web-focused | Built-in | Harder |
| Notepad (Windows) | Free | No highlighting | None | Instant |
VS Code is the best balance: completely free, but professional grade. This is what Google, Microsoft and Netflix developers use. Learn it now and this knowledge will serve you for decades.
3Installation โ step by step
https://code.visualstudio.com
Windows, Mac and Linux versions are all available here. Choose the one that matches your operating system.
1. Go to: https://code.visualstudio.com 2. Click the big blue "Download for Windows" button 3. Run the downloaded VSCodeSetup-x64-*.exe file 4. During installation, keep these boxes checked: โ "Add to PATH" โ important! โ "Register Code as editor for supported file types" โ "Add 'Open with Code' action to Windows Explorer" 5. After installation, launch VS Code 6. The welcome screen opens โ you're ready!
First launch โ what you'll see
A welcome screen appears on first launch. You can close it. The most important areas:
On the left โ your files and folder tree. This is where you open HTML files.
This is where you write code. Multiple files can be open at once as tabs.
Built-in command line. Not needed yet, but useful later.
Where you install extensions. Go here for Live Server.
4Essential extension: Live Server
Live Server is the most important extension for this course. Without it you need to press F5 to refresh the browser after every save โ with it the browser refreshes automatically the moment you save.
1. In VS Code press Ctrl+Shift+X (Extensions panel) 2. Type in the search box: "Live Server" 3. Find "Live Server" โ by Ritwick Dey 4. Click the "Install" button 5. After installing, the status bar shows: "Go Live" โ click this to start serving Usage: - Open an HTML file - Click "Go Live" (bottom right corner) - Browser opens automatically: http://127.0.0.1:5500 - Every save (Ctrl+S) triggers an instant refresh!
Prettier โ automatically formats your code on save
Auto Rename Tag โ rename the opening tag and the closing tag updates too
Color Highlight โ shows the actual colour next to codes like #ff0000
5Most useful keyboard shortcuts
| Shortcut | What it does | When it's useful |
|---|---|---|
Ctrl + S | Save | After every change โ Live Server watches for it |
Ctrl + Z | Undo | When you made a mistake |
Ctrl + / | Toggle comment | Quickly comment out a line |
Alt + โโ | Move line | Rearrange code without copy-paste |
Ctrl + D | Select next match | Edit multiple occurrences at once |
Ctrl + F | Find in file | Locate a tag or variable |
Ctrl + Shift + F | Find in all files | Project-wide search |
F12 | Go to definition | Jump to where a function or variable is defined |
Ctrl + ` | Open terminal | Command line inside VS Code |
Shift + Alt + F | Format document | Instantly tidy up messy code |
6Opening Castle Siege in VS Code
Let's try it for real! Open the castle_siege.html file in VS Code and see how the code appears.
1. In VS Code: File โ Open Folder (not File โ Open File!) โ Select the folder where the games are stored โ All files appear in the left panel 2. Click "castle_siege.html" in the left panel โ It opens in the editor โ Can you see syntax highlighting? Red tags, yellow attributes? 3. Click "Go Live" (bottom right corner) โ Opens in the browser and is playable! 4. Try it: find the <title> tag (Ctrl+F โ "title") โ Change its text โ Save (Ctrl+S) โ watch the browser tab!
Castle Siege is nearly 900 lines of code. That may look daunting at first โ but by the end of the course you'll understand every single line. In the first lessons we only look at the first 15 lines.
Install VS Code and complete these tasks:
- Install VS Code from code.visualstudio.com
- Install the Live Server extension (by Ritwick Dey)
- Open the games folder (File โ Open Folder)
- Open castle_siege.html โ can you see the syntax highlighting?
- Launch with Live Server (Go Live button) โ does the game run in the browser?
- Find the <title> tag (Ctrl+F), change its text, save (Ctrl+S) โ did the tab title change?
๐ง Which statement about VS Code is true?
The HTML Document Structure
We learn the "skeleton" of a webpage โ the frame that holds everything else. We'll see how this same structure looks in the Castle Siege game.
1What is HTML?
HTML (HyperText Markup Language) is not a programming language โ it's a markup language. We use it to say what is on the webpage and what each thing is. Our job is not to give instructions to the machine, but to give structure to content.
HTML is like a building's floor plan. It shows where the door, windows and walls are โ but doesn't say what colour they should be. Colours are CSS's job, and movement (who opens the door) is JavaScript's.
HTML is made of tags (markers). Every tag has an opening and a closing version:
<h1>This is a heading</h1> <!-- โ opening tag โ closing tag (starts with a slash) --> <p>This is a paragraph.</p> <!-- Some tags are self-closing (they have no content): --> <br> <!-- line break --> <img src="image.jpg"> <!-- image -->
2The basic document structure
Every HTML file must start like this. It's not optional โ this is what the browser expects:
<!DOCTYPE html> <!-- 1. This is an HTML5 document --> <html lang="en"> <!-- 2. The page language --> <head> <!-- 3. Head (not visible) --> <meta charset="UTF-8"> <!-- special chars work --> <meta name="viewport" content="width=device-width"> <!-- mobile view --> <title>Page Title</title> <!-- browser tab --> <style> /* CSS goes here */ </style> </head> <body> <!-- 4. Body (this is visible) --> <h1>Hello World!</h1> <script> // JavaScript goes here </script> </body> </html>
We see exactly this in Castle Siege
Open castle_siege.html in a text editor โ its first 10 lines are exactly this structure, just with a different title and content:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Castle Siege โ 50 Levels</title> <style> /* ... all the styles live here ... */ </style> </head> <body> <canvas id="c"></canvas> <!-- the game canvas --> <div id="hud">...</div> <!-- speed buttons --> <script> // ... all the JavaScript lives here ... </script> </body> </html>
Castle Siege's <body> contains just 3 things: a <canvas>, a <div>, and a <script>. 99% of the game lives inside the script โ but the HTML frame is always the same.
3The four main elements explained
| Element | What it does | Where you see it in the game |
|---|---|---|
<!DOCTYPE html> | Tells the browser this is HTML5 โ mandatory first line | Castle Siege, Froggy Rush, Turtle Race โ always the very first line |
<html lang="en"> | Root of the whole document; the lang attribute helps screen readers and search engines | All our games have lang="en" (or the original Hungarian) |
<head> | Meta-data, title, styles โ the user does NOT see this directly | Castle Siege's <head> contains all CSS styles (300+ lines) |
<body> | Visible content โ what appears in the browser | Froggy Rush's body contains the canvas, D-pad buttons and modal window |
4Comments in the code
Comments are only for the code reader โ the browser ignores them completely. They're very important so you can understand your own code later.
<!-- This is a single-line HTML comment --> <!-- This is a multi-line comment --> <canvas id="c"></canvas> <!-- the game canvas, controlled by JavaScript -->
Create your very first HTML file! Open a text editor, create a file called mypage.html, and type in the basic structure.
- Include the correct DOCTYPE, html, head, body structure
- Set the title to "My First Page"
- Inside the body write your name in an h1 tag
- Add a comment explaining what the h1 does
- After saving, double-click to open in the browser โ does your name appear?
๐ง Quick check โ which statement is true?
Text, Headings, Lists
We learn how to display text โ and how this looks in our games' interfaces.
1Headings โ h1 to h6
HTML has 6 levels of heading. <h1> is the most important (largest), <h6> is the smallest. A page should only have one <h1>!
<h1>๐ธ Froggy Rush!</h1> <!-- largest --> <h2>Current Level</h2> <h3>Statistics</h3> <h4>Controls</h4> <!-- rarely used --> <h5>Footer note</h5> <!-- even rarer --> <h6>Legal text</h6> <!-- smallest -->
In Froggy Rush: <h1>๐ธ FROGGY RUSH!</h1> โ this is exactly what you see above the game. The browser renders it large and bold automatically.
Paragraphs and text formatting
<p>This is a paragraph. It can contain multiple sentences.</p> <p>This is <strong>bold</strong> text โ for important emphasis.</p> <p>This is <em>italic</em> text โ for subtle stress.</p> <br> <!-- line break (self-closing, no </br>) --> <hr> <!-- horizontal dividing line --> <code>Math.floor(Math.random() * 10)</code> <!-- inline code -->
Lists
<!-- Unordered list โ with bullet points --> <ul> <li>Froggy Rush</li> <li>Turtle Race</li> <li>Castle Siege</li> </ul> <!-- Ordered list โ with numbers --> <ol> <li>Open in browser</li> <li>Use arrow keys to steer</li> <li>Collect the eggs</li> </ol>
<ul> โ when order doesn't matter (e.g. listing game rules)
<ol> โ when order matters (e.g. steps in sequence)
Expand your previous file with text content!
- Add an h2 subheading: "My Favourite Games"
- Below it, a ul list with the three games
- In a paragraph, briefly write why you enjoy games โ highlight one word with strong
- Add an ol list: how to launch Froggy Rush (3 steps)
๐ง Which list element has the correct syntax?
Links and Images
Linking is the essence of the web. We learn how to connect pages โ and how to display images. The links on our game portal are all built this way.
1Links โ <a> tag
<!-- External link โ to another website --> <a href="https://netlify.com">Netlify website</a> <!-- Internal link โ to your own file --> <a href="castle_siege.html">Castle Siege game</a> <!-- Opens in a new tab --> <a href="froggy_rush.html" target="_blank">Froggy Rush</a> <!-- Jump within the same page (anchor) --> <a href="#l2">Jump to Lesson 2</a> <!-- ... then somewhere on the page: --> <h2 id="l2">Lesson 2</h2>
Images โ <img> tag
<!-- Basic image --> <img src="frog.png" alt="A green frog"> <!-- With dimensions --> <img src="turtle.png" alt="Turtle character" width="200" height="150"> <!-- Image as a link --> <a href="turtle_race.html"> <img src="preview.png" alt="Turtle Race"> </a>
The alt text is displayed if the image fails to load โ and it's what screen readers read aloud for visually impaired users. Always give a meaningful alt text.
Build the foundation of your own game portal! In one HTML file:
- h1 heading: "My Games"
- Three links to the three games (castle_siege.html, froggy_rush.html, turtle_race.html)
- Each link should have target="_blank" (opens in new tab)
- Create a "contact" anchor at the bottom of the page and link to it from the top
๐ง Which attribute opens a link in a new browser tab?
div, span, id and class
The "boxes" of HTML โ we use these to group elements together. Every panel in Castle Siege and Froggy Rush is built on exactly this.
1div โ block-level container
The <div> (division) is an invisible box that groups elements together. On its own it does nothing โ but combined with CSS and JavaScript it's one of the most important tools in web development.
<!-- A panel for the speed-change buttons --> <div id="hud"> <span>Speed:</span> <!-- Each button is a button element inside the div --> <button class="sb on" id="s0">๐ Child</button> <button class="sb" id="s1">๐ข Slow</button> <button class="sb" id="s2">โ๏ธ Normal</button> </div>
id vs class โ what's the difference?
| Property | id | class |
|---|---|---|
| Uniqueness | Can appear only once per page | Can be used on multiple elements |
| CSS syntax | #hud { ... } | .sb { ... } |
| JS syntax | getElementById('hud') | getElementsByClassName('sb') |
| When to use | To identify a unique element (canvas, modal) | For reusable styles (buttons, cards) |
id="hud" is unique โ there's only one HUD on the entire page.
class="sb" (speed button) appears on 4 buttons โ they all share the same style.
span โ inline-level container
<!-- div: starts a new line (block element) --> <div>This is a block โ takes up the full line.</div> <div>This goes on the next line.</div> <!-- span: stays inline (inline element) --> <p>Score: <span id="ui-score">0</span> points.</p> <!-- The span only wraps the "0", the paragraph stays continuous --> <!-- Froggy Rush also displays the score this way: --> <div class="pbox"> <div class="plabel">Score</div> <div class="pval" id="ui-score">0</div> </div>
Build your game portal's panel structure using divs!
- Create an id="header" div for the title and navigation
- Create an id="games" div containing 3 divs each with class="game-card"
- Each card should contain: h3 (game name), p (short description), a (link to game)
- Create an id="footer" div at the bottom of the page
๐ง What's the difference between id and class?
Buttons and Input Elements
Castle Siege's save system, its speed buttons and its modal window all have HTML inputs. Now we understand them.
1Buttons and text fields
<!-- The save modal window --> <div id="modal-bg"> <div id="modal"> <!-- Text input field --> <input id="save-name" maxlength="12" placeholder="Enter your name..."> <!-- Buttons --> <button class="mb" onclick="doSave()">๐พ Save</button> <button class="mb" onclick="closeModal()">โ Cancel</button> </div> </div>
A clickable button. JavaScript can be run in the onclick attribute.
Single-line text input. The save system uses this to ask for a name.
Only accepts numbers. Useful for level or score inputs.
A tick box. For settings and options.
Faint hint text in an empty field โ disappears when typing starts.
Maximum character count in the field (Castle Siege: 12).
Add a "Player Registration" section to your portal!
- Name field (input, maxlength=15, placeholder="Your name")
- Favourite game dropdown (select + 3 options)
- "Register" button (button, onclick=alert('Hi!'))
- Give buttons a class attribute for styling
๐ง Which input type only accepts numbers?
CSS โ Colour, Font, Size
CSS gives our games their visual appearance. In this first CSS lesson we learn colours, fonts and sizes โ through Castle Siege's dark theme.
7Lesson โ Colour, Font, Size
/* CSS variables โ the entire game's colour palette in one place */ :root { --bg: #0d0a05; /* dark background */ --player: #00d4ff; /* blue โ player colour */ --ai: #ff3d6e; /* red โ AI colour */ --gold: #FFD700; /* gold โ score colour */ } /* Base style for the whole page */ body { background: var(--bg); /* using a variable */ color: #c4a870; /* text colour */ font-family: Georgia, serif; /* font */ font-size: 15px; /* font size */ } /* Button styles */ .sb { background: #1a1208; border: 1px solid #5a3a10; /* width | style | colour */ color: #c4a870; border-radius: 4px; /* rounded corners */ cursor: pointer; /* hand cursor on hover */ } .sb.on { /* active button style */ background: #3a2010; border-color: #FFD700; color: #FFD700; }
Variables declared in :root (--name: value) can be used anywhere in the file. To change a colour, you only need to edit one place โ this is the professional approach.
Style your game portal page with CSS:
- Give the body a dark background (
background: #1a1a2a) - Change the text colour to light (
color: #c4d0e0) - Set a Google Fonts typeface (Fredoka One or Nunito)
- Define 3 CSS variables in :root: --bg, --text, --highlight
- Use these variables in your styles
๐ง How do you USE (not define) a CSS variable?
CSS โ Box Model
Why is something not where you expected it? The box model explains it. Every HTML element is a box โ its size is the sum of content, padding, border and margin.
8Lesson โ Box Model
.game-card { width: 300px; /* content width */ padding: 20px; /* inner spacing (around content) */ margin: 10px; /* outer spacing (around element) */ border: 2px solid #444; /* border */ /* Actual width = width + padding*2 + border*2 = 300 + 40 + 4 = 344px (unless box-sizing: border-box is set) */ } /* Modern approach โ padding and border are included in width */ * { box-sizing: border-box; /* present in all our games! */ }
Box model experiments โ open browser DevTools (F12 โ Elements):
- Give the game cards
padding: 20pxโ what happens? - Give one card
border: 3px solid #4d9fff - Add * { box-sizing: border-box } โ did anything change?
- In F12, look at the "Box Model" diagram in the Elements panel โ can you see the margin/padding/border layers?
๐ง What does box-sizing: border-box do?
CSS โ Flexbox Layout
Flexbox is the modern web layout system. All the HUD panels and button rows in our games are arranged with this.
9Lesson โ Flexbox
/* Arranging speed buttons in a row */ #hud { display: flex; /* enable flexbox */ align-items: center; /* vertically centred */ gap: 10px; /* space between items */ flex-wrap: wrap; /* wrap on small screens */ } /* Froggy Rush page layout */ #layout { display: flex; gap: 16px; justify-content: center; /* centred horizontally */ } /* Fixing the side panel width */ #panel { width: 160px; flex-shrink: 0; /* don't let it shrink */ }
Use Flexbox to arrange the game portal cards:
- Give the #games div
display: flex - Add
gap: 20pxbetween cards - Centre them:
justify-content: center - Try
flex-direction: columnโ what changes? - Switch back to
rowand addflex-wrap: wrap
๐ง Which CSS property centres flex items horizontally?
CSS โ Responsive Design
How does the game look on mobile? With @media rules our games work perfectly on phones and tablets.
10Lesson โ Responsive Design
/* Desktop view: two columns side by side */ #layout { display: flex; flex-direction: row; /* horizontal */ } /* If screen is smaller than 768px (tablet/phone): */ @media (max-width: 768px) { #layout { flex-direction: column; /* stacked vertically */ } #panel { width: 100%; /* full width */ } } /* If the device is touch (phone/tablet) โ D-pad appears */ @media (pointer: coarse) { #dpad { display: flex; /* only visible on touch devices */ } }
Make the game portal mobile-friendly with @media rules:
- Add a @media (max-width: 768px) block to your CSS
- On mobile, stack cards vertically:
flex-direction: column - On mobile, make cards full width:
width: 100% - Test with Chrome DevTools: F12 โ phone icon โ can you see the mobile view?
๐ง Which @media condition activates when the screen is smaller than 768px?
๐ Phase Project โ Game Portal Page
The closing project for Phase 1. You now know all the HTML and CSS basics โ it's time to put together a real, stylish game portal page.
11Lesson โ ๐ Phase Project: Game Portal Page
You now know all the necessary HTML and CSS fundamentals. It's time to assemble a real, stylish game portal page where your three games appear as links โ just like a proper website.
Requirements
<!DOCTYPE html> <html lang="en"> <head> <!-- charset, viewport, title --> <!-- CSS: dark theme, flex layout, card styles --> <!-- @media responsive rules --> </head> <body> <div id="header"> <h1>๐ฎ My Games</h1> <p>Three browser games I built myself</p> </div> <div id="games"> <!-- 3 cards, each containing: --> <div class="card"> <h2>๐ฐ Castle Siege</h2> <p>Tower defence game with 50 levels</p> <a href="castle_siege.html" target="_blank"> <button class="play-btn">โถ Play</button> </a> </div> <!-- ... 2 more cards ... --> </div> <div id="footer"> <p>Made by: <strong>[Your name]</strong></p> </div> </body> </html>
- Correct HTML5 document structure (DOCTYPE, html, head, body)
- Special characters display correctly (charset UTF-8)
- Readable on mobile (@media and viewport)
- Dark background, readable text (CSS color + background)
- 3 game cards in flex layout side by side (desktop)
- Cards stack vertically on mobile (@media)
- Every card has a link to the game (target="_blank")
- Buttons change on hover (:hover CSS)
- Header and footer are clearly separated
- Code is tidy and commented