Week 1 — HTML5 Foundations
Before we can build games we need to speak the language of the web. This week you meet the HTML5 document skeleton, the elements that hold content, and your first line of CSS and JavaScript.
🎯 Objectives
- Write a valid HTML5 page:
<!DOCTYPE html>,<html>,<head>,<title>,<body>. - Use headings, paragraphs, lists, images (
<img>) and links (<a>). - Understand attributes such as
src,href,widthandalt. - Style a page with embedded CSS (selectors, colours, fonts, spacing).
- Add interactivity with a
<script>element and a click handler. - Tell the difference between content (HTML) and presentation (CSS).
🛠 Weekly tasks
- Objective 1 — write a valid HTML5 skeleton (
DOCTYPE,html,head,title,body): Activity 1 + buildsimple.html. - Objective 2 — headings, paragraphs, lists, images and links: Activity 2 + build
starter.htmlandsecond.html. - Objective 3 — attributes (
src,href,width,alt): Activity 3 + buildsecond.html. - Objective 4 — embedded CSS (selectors, colours, fonts, spacing): Activity 4 + style
third.html. - Objective 5 — a
<script>element and a click handler: Activity 5 + buildstarter.htmlandfavoriteSites.html. - Objective 6 — content vs presentation: Activity 6 + reformat
secondSpacedOut.html. - Build your own
myGamePage_yourname.html— using everything you have learned. (All objectives)
🎓 Lecture activity Open lecture slides →
A 90-minute session of 35 slides. Each concept is taught four ways: the big idea, a short example with its live output, a line-by-line explanation, and a 5-minute “try it” task. The lab work at 1:00 uses the Lab activity below.
Session plan
- 0:0010 minWarm-upReview questions on last week
- 0:1010 minGame & objectivesThis week’s game, objectives and key words
- 0:2035 minConceptsBig idea → code with live output → line by line → try it
- 0:555 minCheck understandingCommon mistakes and a 4-question quiz
- 1:0025 minLabBuild the files in the Lab activity below
- 1:255 minWrap-upBuild-your-own task, marking guide and recap
Concepts this week
- 1. Page structure — The anatomy of a web page
- 2. Images & links — Attributes add the details
- 3. Styling with CSS — Selectors pick, properties style
- 4. Events & functions — A click runs a function
The slides open as a page on this site. Press F for full screen, the arrow keys to move, N for speaker notes, and P to save as PDF (turn on “Background graphics”).
🧪 Lab activity: work through the files Printable lab sheet
Create a folder named Week1 on your PC. For each file below, open your
editor, create the file (for example starter.html) and copy the code provided below
into it. Work through the files in order; save each one and refresh the browser. Each file
builds on the objectives from the one before. Tick a checkpoint once you have proved it works.
-
Create your Week1 folder
On your own PC — do this once before starting.
- Create a folder named
Week1on your PC (for example on the Desktop). - Open your
Week1folder in VS Code or Sublime Text. - For each file below, create it in your editor (for example
starter.html) and copy the code provided into it. - Scroll down to the Materials for this week panel and press Download
(or Download all) to save the image files
(
frog.gif,frogface.gif,flappingBird.png,purchaseMathCS.png,avivasmugmug.png,apressshot.png) into yourWeek1folder.
Week1\ starter.html simple.html second.html third.html favoriteSites.html secondSpacedOut.html myGamePage.html frog.gif frogface.gif flappingBird.png purchaseMathCS.png avivasmugmug.png apressshot.png - Create a folder named
-
starter.html Objectives 2, 4, 5
Week1\starter.html — a complete interactive page to explore first.
- Create
starter.htmlfile and open it in your editor.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>My First Web Game Page</title> </head> <body> </body> </html> - Add the heading, paragraph, score display, button, image and list inside
<body>.<h1>Click the Frog!</h1> <p>Press the button to score a point.</p> <div id="score">0</div> <button onclick="score()">Click me</button> <br /> <img src="frog.gif" alt="a friendly frog" /> <p>Things I will learn this week:</p> <ul style="display:inline-block;text-align:left;"> <li>HTML document structure</li> <li>Elements and attributes</li> <li>Images and links</li> <li>A little CSS and JavaScript</li> </ul> - Add a
<style>block in<head>.<style> body { font-family: Arial, sans-serif; background-color: #f4f1e8; color: #2b2b2b; text-align: center; padding: 30px; } h1 { color: #1b6b4a; } #score { font-size: 64px; font-weight: bold; color: #c0392b; margin: 10px 0; } button { font-size: 18px; padding: 12px 26px; border: none; border-radius: 8px; background: #1b6b4a; color: white; cursor: pointer; } button:hover { background: #145238; } img { margin-top: 18px; } </style> - Add the
<script>with the counter.<script> var points = 0; function score() { points = points + 1; document.getElementById("score").textContent = points; } </script> - Find and name the four blocks:
<title>,<h1>, the<style>block and the<script>block. - Save, refresh, and click the button to test it.
- Create
-
simple.html Objective 1
Week1\simple.html — the smallest valid page.
- Create
simple.htmlfile and notice how little it contains.<html> <head> <title>Very simple example</title> </head> <body> This will appear as is. </body> </html> - Add
<!DOCTYPE html>as the very first line andlang="en"to the<html>tag.<!DOCTYPE html> <html lang="en"> - Add an
<h1>heading and a<p>paragraph inside<body>.<h1>Hello</h1> <p>This will appear as is.</p> - Add an HTML comment
<!-- my first page -->and confirm it does not show on screen.<!-- my first page --> - Save and refresh. Press Ctrl+U (View Page Source) to see the raw HTML, then compare it with the rendered page — the comment stays hidden, while the
<h1>and<p>appear as a heading and a paragraph.
- Create
-
second.html Objectives 2 & 3
Week1\second.html — images, links and attributes.
- Create
second.htmland add this scaffold code.<!DOCTYPE html> <html lang="en"> <head> <title>Second example</title> </head> <body> This will appear as is. </body> </html> - Add an image with
srcandalt.<img src="frog.gif" alt="a friendly frog" /> - Add a second image with a
widthattribute.<img src="frog.gif" alt="a big frog" width="200" /> - Add a text link with
href.<a href="http://www.purchase.edu">Purchase College/SUNY</a> - Add an image link (wrap an image in
<a>).<a href="https://www.purchase.edu/academics/mathematics-computer-science/"> <img src="purchaseMathCS.png" alt="math and computer science" width="300" /> </a> - Break an image
srcon purpose, refresh, and watch thealttext appear; then fix it. - Save and refresh, then click the links to test them.
- Create
-
third.html Objective 4
Week1\third.html — embedded CSS and semantic tags.
- Create
third.htmland add this scaffold code.<!DOCTYPE html> <html lang="en"> <head> <title>CSS example</title> </head> <body> </body> </html> - Add a
<style>block in<head>and style thebody(colour, font, alignment).<style> body { background-color: tan; color: #660000; text-align: center; font-size: 22px; } </style> - Add the
sectionrule (width, border, padding, margin, background).section { width: 85%; border: 4px #00FF63 solid; text-align: left; padding: 5px; margin: 10px; background-color: white; } - Add the
pandasiderules.p { width: 75%; } aside { font-style: italic; } - Add the body text and the first
<section>with an image.The background here is tan and the text is the totally arbitrary RED GREEN BLUE value #660000. <br/> <section> This section has text--this sentence--and then a paragraph with an image, and text. <p> <img src="frogface.gif" alt="frogface model" /> The frogface model can be made to move its jaw. </p> </section> - Add the second
<section>with an image and an<aside>with links.<section> As you may have noticed, I like origami. <p> The next image is a photo of the Flapping Bird, in action. <br/> <img src="flappingbird.png" alt="flapping bird" width="200" /> </p> <aside> There are many books and websites to learn how to fold the Flapping Bird. Here is a plug for one of my origami books <a href="https://origamiusa.org/catalog/products/origami-explanations">Origami with Explanations</a> ... Visit my <a href="https://www.amazon.com/Jeanine-Meyer/e/B001JPA5SC">Jeanine Meyer Author page</a>. </aside> </section> - Save and refresh.
- Create
-
favoriteSites.html Objectives 2, 4 & 5
Week1\favoriteSites.html — articles, styling and a script.
- Create
favoriteSites.htmland add this scaffold code.<!DOCTYPE html> <html lang="en"> <head> <title>Annotated links</title> </head> <body> <h3>Favorite Sites</h3> </body> </html> - Add a
<style>block with thearticleandimgrules.<style> article { width: 60%; text-align: left; margin: 10px; border: 2px green double; padding: 2px; display: block; } img { display: block; } </style> - Add a
<script>that writes the date.<script> document.write(Date()); </script> - Add the first
<article>with a link.<article> The <a href="http://www.purchase.edu/">website for Purchase College/State University of New York</a>. </article> - Add the second
<article>with a link and a screenshot image.<article> The <a href="https://avivameyer.smugmug.com/">Aviva Meyer's photographs</a> site is a collection of photographs. <img src="avivasmugmug.png" alt="Aviva Meyer's photographs" width="400" /> </article> - Add the third
<article>with a link and a screenshot image.<article> <a href="http://apress.com">Apress publishers</a> is the site for the publishers of this book. <br/> <img src="apressshot.png" alt="Apress screenshot" width="400" /> </article> - Save and refresh, then check the date and the links.
- Create
-
secondSpacedOut.html Objectives 1 & 6
Week1\secondSpacedOut.html — structure vs presentation.
- Create
secondSpacedOut.htmlfile and add the messy markup below.<html> <head> <title>Second example Spaced Out</title> </head> <body> This will appear as is. <br/> <img src="frog.gif"/> <img src="frog.gif" width="200"/> <br/> <a href=http://www.purchase.edu>Purchase College/SUNY</a><br/> <br/> <a href=https://www.purchase.edu/academics/mathematics-computer-science/><img src="purchaseMathCS.png" width="500"/></a> </body> </html> - Compare it with
second.html. - Add the missing
<!DOCTYPE html>andlang="en".<!DOCTYPE html> <html lang="en"> - Reformat the markup so every tag starts on its own line, is indented, and add
altto the images.<!DOCTYPE html> <html lang="en"> <head> <title>Second example Spaced Out</title> </head> <body> This will appear as is. <br/> <img src="frog.gif" alt="frog" /> <img src="frog.gif" alt="big frog" width="200" /> <br/> <a href="http://www.purchase.edu">Purchase College/SUNY</a><br/><br/> <a href="https://www.purchase.edu/academics/mathematics-computer-science/"> <img src="purchaseMathCS.png" alt="math and computer science" width="500" /> </a> </body> </html> - Keep the visible output exactly the same as before.
- Write one sentence (as a comment) explaining why indentation does not change what the user sees.
<!-- Indentation does not change the page: the browser collapses whitespace. --> - Save and refresh.
- Create
-
myGamePage.html → myGamePage_yourname.html All objectives
Week1\myGamePage.html — copy it, rename it, then build your own page.
- Create
myGamePage_yourname.htmlfile (or copymyGamePage.htmland rename it) and add the page skeleton.<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>My Game</title> </head> <body> </body> </html> - Set your own
<title>, and add an<h1>, an intro<p>, an<img>and a link.<h1>My Game</h1> <p>This is my first web game page.</p> <img src="frog.gif" alt="a friendly frog" width="150" /> <p><a href="https://www.w3schools.com/html/" target="_blank">Learn more about HTML</a></p> - Add a
.carddiv with a<ul>of features.<div class="card"> <h2>Features</h2> <ul> <li>Fast</li> <li>Fun</li> <li>Free</li> </ul> </div> - Add another
.carddiv with an<ol>of steps.<div class="card"> <h2>How to play</h2> <ol> <li>Press start</li> <li>Score points</li> <li>Beat the high score</li> </ol> </div> - Add embedded CSS using an element (
body,h1), a class (.card) and an id (#score) selector.<style> body { background: #0f1420; color: #e8edf7; font-family: Arial, sans-serif; text-align: center; padding: 30px; } h1 { color: #4f8cff; font-size: 40px; } #score { font-size: 64px; font-weight: bold; color: #22d3a6; } .card { background: #1b2436; border: 1px solid #2b3852; border-radius: 12px; padding: 16px; margin: 14px auto; width: 60%; } </style> - Add the score display, a button and a
<script>that increases#scorewhen clicked.<div id="score">0</div> <button id="btn">Click me</button> <script> var points = 0; function score() { points = points + 1; document.getElementById("score").textContent = points; if (points === 10) { alert("Well done, 10 points!"); } } document.getElementById("btn").addEventListener("click", score); </script> - Screenshot the page with and without CSS, answer the content-vs-presentation questions, and check F12 → Console for errors.
- Create
📝 Tasks for this file:
This page previews each game in the box above. Edit the game files in VS Code or Sublime Text, then double-click the file (or refresh its browser tab) to see your changes.