Web Technologies 2026 · BiUH · Recap · Lessons 2–4

Your site,
by hand

Rebuild it from an empty folder — HTML · CSS · structure · navigation · DRY

webtech.landrock.io

Where this ends

One folder. Four pages, and the pieces they share.

FileWhat it isFrom
index.htmlthe homepage — a hero image, and a way into the other threelesson 2
quotes.htmlthe quote collectionexercise
project.htmlyour project ideaslesson 4
about.htmlwho you are, and how to reach youlesson 2
style.cssone stylesheet for every pagelesson 3
nav.html · footer.htmlthe navigation and the footer — fragments, written oncelesson 4
nav.jsputs the navigation (and the footer) into every pagelesson 4
favicon-32.png · apple-touch-icon.pngthe icon — square, 32 × 32 and 180 × 180lesson 4
images/the hero image, and your photoslesson 2

How to use this recap

Every code block has a Copy button.

<p>Try it. Click Copy, then paste.</p>

It copies the code and does not turn the page. Paste with Ctrl+V — ⌘+V on a Mac.

Type it if you can. Your hands learn the shape of HTML faster than your eyes do.

If you copy it, read every line you pasted. You must be able to explain all of it — that is what is assessed.

Long files scroll inside their box — Copy always takes the whole file. Selecting code with the mouse never turns the page either.

Step 0 · before any code

A folder, an editor, a server.

  1. Make a folder called my-site — lower case, no spaces
  2. VS Code → File → Open Folder… → choose it
  3. Extensions panel → search Live Server → Install
  4. Once index.html exists: right-click it → Open with Live Server

Your page opens at http://127.0.0.1:5500 and reloads every time you save.

Use it from the start. The navigation at the end of this recap only works over http:// — never over file://.

Part 1 · Lesson 2

HTML says what
things are.

A heading, a paragraph, a quotation, a navigation. What they look like is CSS's job.

Every page starts here

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Page title</title>
</head>
<body>
  <!-- everything people see -->
</body>
</html>
<!DOCTYPE html>modern HTML — without it, browsers fall back to 1990s behaviour
lang="en"which language a screen reader pronounces
charset="UTF-8"without it, 中文 and emoji turn to nonsense
viewportwithout it, a phone shows your page at desktop width, shrunk

Four lines that are not decoration. Each one prevents a real, visible problem.

The head · nobody sees it, machines read all of it

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Quotes · Li Wei</title>

  <link rel="icon" href="favicon-32.png" sizes="32x32">
  <link rel="apple-touch-icon" href="apple-touch-icon.png">

  <link rel="stylesheet" href="style.css">
</head>
<title>the text in the browser tab — different on every page
rel="icon"the favicon. A square PNG, 32 × 32
rel="apple-touch-icon"a phone's home screen. 180 × 180 — a separate file, not the small one stretched
rel="stylesheet"one CSS file, linked from every page

charset goes first: the browser needs it before it reads any text.

The body · nearly every page you have ever used

Four parts — learn the names.

<header> logo · site name <nav> Home · Quotes · Project ideas · About <main> the reason they came <footer> contact · copyright who this is where you can go the small print the only part that changes per page these three are the same on every page

<head> is about the page. <header> is the top of the page. Four letters apart, completely different jobs.

The body, in code · the same on all four pages

<body>
  <header id="site-header"></header>

  <main>
    <!-- the only part that differs per page -->
  </main>

  <footer id="site-footer"></footer>

  <script src="nav.js"></script>
</body>

The header and the footer stay empty in the file. nav.js fills them with the navigation and the footer — that is Part 4.

The ids are how the script finds them. The script goes last, so both elements exist before it runs.

Headings are an outline, not font sizes

One <h1>. Never skip a level.

✓ An outline

<h1>Li Wei</h1>
  <h2>What I am learning</h2>
  <h2>On this site</h2>
    <h3>Quotes</h3>

✗ Chosen by size

<h1>Li Wei</h1>
  <h4>What I am learning</h4>
  <h2>On this site</h2>
    <h5>Quotes</h5>

Screen reader users jump from heading to heading. Want smaller text? That is CSS.

Text · two pairs that look identical and are not

✓ Meaning

<strong>Warning</strong>
<em>really</em>

A screen reader stresses these aloud.

✗ Appearance only

<b>Warning</b>
<i>really</i>

Bold and italic pixels. No meaning attached.

Every paragraph is a <p>. Not a line break, not a <div> — a paragraph.

Same pixels on screen. Only one survives being heard instead of seen.

Links · the element that made the web a web

<a href="quotes.html">Quotes</a>              <!-- another page of mine -->
<a href="../index.html">Home</a>            <!-- up one folder -->
<a href="https://developer.mozilla.org">MDN</a>  <!-- someone else's site -->
<a href="about.html#contact">Contact</a>  <!-- a place on another page -->
<a href="mailto:liwei@example.com">Mail</a>  <!-- open a mail program -->

Relative for your own pages — it still works when the site moves to a server. Absolute, with https://, only for other sites.

Link text is read out of context. "Click here" tells a screen reader nothing. Say where it goes.

Images · two attributes, and one is not optional

<img src="images/hero.jpg" alt="The BiUH campus at sunrise, seen from the lake">
srcwhere the file is — a relative path, exact spelling and capitals
altwhat it shows — as if describing it to someone on the phone
alt=""purely decorative: empty, but present
1600 pxwide is plenty for a hero photo. Never upload a 4 MB camera original — resize it, WebP if you can

An image without alt is invisible to anyone who is not looking at it.

Not sure which element? Ask in this order.

Is it …Use
navigation links?<nav>
the main content of the page?<main>
something that stands alone — a post, a product, a quote?<article>
a themed part with its own heading?<section>
only loosely related — a sidebar?<aside>
an introduction, or the small print?<header> <footer>
none of the above?<div>

<div> is not wrong. It is the honest answer when nothing more specific fits.

Part 2 · build

Four pages

The same skeleton every time. Only <title> and <main> change.

The homepage · one picture, one name, three ways in

.hero img {
  width: 100%;
  height: 20rem;
  object-fit: cover;
  border-radius: 10px;
}

object-fit: cover fills the box and crops the rest. The photo is never squashed.

The hero is the first screen of the homepage: one strong image, the site's name, one sentence. Below it, a door to each of the other three pages.

index.html · the whole file

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Li Wei</title>
  <link rel="icon" href="favicon-32.png" sizes="32x32">
  <link rel="apple-touch-icon" href="apple-touch-icon.png">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header id="site-header"></header>

  <main>
    <section class="hero">
      <img src="images/hero.jpg" alt="The BiUH campus at sunrise, seen from the lake">
      <h1>Li Wei</h1>
      <p>Computer Science at BiUH — and a website written entirely by hand.</p>
    </section>

    <h2>On this site</h2>
    <ul>
      <li><a href="quotes.html">Quotes</a> — things worth reading twice</li>
      <li><a href="project.html">Project ideas</a> — what I might build, and for whom</li>
      <li><a href="about.html">About and contact</a> — who I am, and how to reach me</li>
    </ul>
  </main>

  <footer id="site-footer"></footer>

  <script src="nav.js"></script>
</body>
</html>

Your own name, your own photo — resized to about 1600 px wide. No photo yet? Delete the <img> line: never leave a broken image on a page.

The quote · one structure, used twenty times

<article class="quote">
  <blockquote>
    <p lang="zh">千里之行,始于足下。</p>
    <p>A journey of a thousand miles
       begins beneath your feet.</p>
  </blockquote>
  <footer>
    <cite>Laozi</cite>,
    <span class="source">Tao Te Ching, chapter 64</span>
  </footer>
</article>
<article>one quote — complete on its own
<blockquote>this text is a quotation
<cite>where it came from
lang="zh"this line is Chinese — read it as Chinese. Add a translation below it.
class="quote"a name for CSS: one rule styles all twenty

A <footer> inside an <article> is that article's small print — not the page footer.

quotes.html · the whole file

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Quotes · Li Wei</title>
  <link rel="icon" href="favicon-32.png" sizes="32x32">
  <link rel="apple-touch-icon" href="apple-touch-icon.png">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header id="site-header"></header>

  <main>
    <h1>Quotes</h1>
    <p>Things worth reading twice — each with who said it, and where.</p>

    <article class="quote">
      <blockquote>
        <p>This is for everyone.</p>
      </blockquote>
      <footer>
        <cite>Tim Berners-Lee</cite>,
        <span class="source">London Olympic opening ceremony, 2012</span>
      </footer>
    </article>

    <article class="quote">
      <blockquote>
        <p lang="zh">千里之行,始于足下。</p>
        <p>A journey of a thousand miles begins beneath your feet.</p>
      </blockquote>
      <footer>
        <cite>Laozi</cite>,
        <span class="source">Tao Te Ching, chapter 64</span>
      </footer>
    </article>

    <!-- one <article> per quote — twenty in total -->
  </main>

  <footer id="site-footer"></footer>

  <script src="nav.js"></script>
</body>
</html>

Copy one <article>, change the text, author and source. Every quote needs all three.

Before any CSS · what the browser does on its own

千里之行,始于足下。

A journey of a thousand miles begins beneath your feet.

Laozi, Tao Te Ching, chapter 64
  • the quote is indented — the browser knows it is a quotation
  • <cite> is italic — it knows that is a source

It looks plain. It is also correct.

Nobody styled this. The meaning of the tags did it.

Three kinds of list · the choice carries meaning

<ul>unordered — the order carries no meaning
<ol>ordered — the order is the information
<dl>description list — content that comes in pairs
<li> · <dt> · <dd>list item · the term · its description

Ask: if I shuffled these, would anything be lost? No → <ul>. Yes → <ol>. A name and what it means → <dl>.

You never type the bullets or the numbers. The browser adds them, because you said what kind of list it is.

project.html · the whole file

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Project ideas · Li Wei</title>
  <link rel="icon" href="favicon-32.png" sizes="32x32">
  <link rel="apple-touch-icon" href="apple-touch-icon.png">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header id="site-header"></header>

  <main>
    <h1>Project ideas</h1>

    <h2>Things I might build</h2>
    <ul>
      <li>A site about the food in my hometown</li>
      <li>A portfolio for my photographs</li>
      <li>A guide for new students on campus</li>
      <li>A page for my band</li>
      <li>A recipe converter for people who cook alone</li>
    </ul>

    <h2>Who each one is for</h2>
    <dl>
      <dt>Hometown food</dt>
      <dd>For students who just moved here.</dd>

      <dt>Photo portfolio</dt>
      <dd>For places I want to apply to.</dd>

      <!-- one <dt> and one <dd> per idea -->
    </dl>

    <h2>How I will build it</h2>
    <ol>
      <li>Sketch it</li>
      <li>Write the HTML</li>
      <li>Style it</li>
    </ol>
  </main>

  <footer id="site-footer"></footer>

  <script src="nav.js"></script>
</body>
</html>

Five ideas, not one — you cannot compare a list of one. "Everyone" is not an answer to who it is for.

about.html · the whole file

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>About · Li Wei</title>
  <link rel="icon" href="favicon-32.png" sizes="32x32">
  <link rel="apple-touch-icon" href="apple-touch-icon.png">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header id="site-header"></header>

  <main>
    <h1>About me</h1>
    <p>I study Computer Science at BiUH. This site is
      <strong>written by hand</strong>, one line at a time.</p>

    <h2>What I am learning</h2>
    <ul>
      <li>HTML — what each part of a page <em>is</em></li>
      <li>CSS — what it looks like</li>
      <li>JavaScript — what it does</li>
    </ul>
    <p>Most of my answers come from
      <a href="https://developer.mozilla.org">MDN Web Docs</a>.</p>

    <section id="contact">
      <h2>Contact</h2>
      <p>Write to me at
        <a href="mailto:liwei@example.com">liwei@example.com</a>.</p>
    </section>
  </main>

  <footer id="site-footer"></footer>

  <script src="nav.js"></script>
</body>
</html>

id="contact" is the place that about.html#contact jumps to — the Contact button in the nav lands here.

Part 3 · Lesson 3

CSS says what it
looks like.

Restyle the whole site without touching a line of content.

The shape of every rule · and where it lives

/* selector { property: value; } */
p {
  color: #333;
  font-size: 16px;
}

Selector — which elements. Property — what aspect. Value — what setting.

<link rel="stylesheet" href="style.css">

External, almost always. Every page, one file to change, cached by the browser.

Not style="…" on an element. Not a <style> block copied into every page.

Forget a semicolon and the next line silently breaks — a classic first-week bug.

Two rules, one element · which wins?

Three questions, in this order.

  1. Importance — is one marked !important? (Don't use it.)
  2. Specificity — is one selector more specific?
  3. Order — still tied? The last one written wins.
pelement0,0,0,1
.quoteclass0,0,1,0
#site-footerid0,1,0,0
style="…"inline1,0,0,0

Rule ignored? DevTools → Styles shows it struck through, with the winner above it. Look there first.

Inheritance and the box model

Inherited — set once on body

color font-family font-size line-height

Not inherited — every box decides

margin padding border background width

Text flows down. Boxes do not.

Every element is a box. DevTools shows this diagram for any element you click — webtech.landrock.io/demos/box-model.html

The header · three things, one row

HomeQuotesProject ideasAbout Contact
logo — leftlinks — centredone action — right
nav {
  display: flex;
  align-items: center;
}

nav .links {
  display: flex;
  margin: 0 auto;
}

display: flex puts the children of <nav> in a row. margin: 0 auto on the middle one takes all the leftover space on both sides — it centres the links and pushes the other two apart.

style.css · the whole file

/* style.css — one file, linked from every page */

/* 1 · Text: set it once on body, everything inside inherits it */
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: #1f2937;
  background: #fbfaf7;
}

/* 2 · The content column */
main {
  max-width: 48rem;
  margin: 0 auto;           /* centred */
  padding: 1rem 2rem;
}

img {
  max-width: 100%;          /* never wider than its box */
  height: auto;
}

/* 3 · The homepage hero: one wide photo, cropped to fit */
.hero img {
  width: 100%;
  height: 20rem;
  object-fit: cover;        /* fill the box, crop the rest — never squash */
  border-radius: 10px;
}

/* 4 · The header: logo left, links centred, action right */
nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
}

nav .links {
  display: flex;
  gap: 1.5rem;
  margin: 0 auto;           /* pushes it to the centre */
  padding: 0;
  list-style: none;         /* no bullets */
}

nav a {
  color: #334155;
  text-decoration: none;    /* no underlines */
}

nav .logo {
  font-weight: 800;
  color: #c2410c;
}

nav .action {
  border: 1.5px solid #0369a1;
  border-radius: 99px;      /* a pill */
  padding: .3em 1em;
  color: #0369a1;
}

nav a:hover {
  color: #c2410c;
}

/* 5 · One quote card — the box model, on all twenty at once */
.quote {
  max-width: 34rem;
  margin-bottom: 1.5rem;    /* space outside */
  padding: 1.1em 1.3em;     /* space inside */
  background: #fff;
  border: 1px solid #dcd8d0;
  border-left: 4px solid #c2410c;
  border-radius: 10px;
}

.quote blockquote {
  margin: 0;                /* drop the browser's indent inside the card */
}

/* 6 · The site footer: by id, because every quote has a <footer> too */
#site-footer {
  padding: 1rem 2rem;
  border-top: 1px solid #dcd8d0;
  color: #6b7280;
}

Scroll inside the code to see all of it. Why #site-footer and not footer? Try footer — and watch every quote change too.

Part 4 · Lesson 4

Write it once.

DRY — Don't Repeat Yourself

The problem

index.html
quotes.html
project.html
about.html

Add one page: four files to edit.
Miss one and your site is quietly broken.

"These are the pages of this site" is one piece of knowledge. It should live in one place.

"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." — Hunt & Thomas, The Pragmatic Programmer, 1999

Step 1 · the navigation, in its own file

<nav>
  <a class="logo" href="index.html">◆ Li Wei</a>

  <ul class="links">
    <li><a href="index.html">Home</a></li>
    <li><a href="quotes.html">Quotes</a></li>
    <li><a href="project.html">Project ideas</a></li>
    <li><a href="about.html">About</a></li>
  </ul>

  <a class="action" href="about.html#contact">Contact</a>
</nav>

A fragment, not a page: no <!DOCTYPE>, no <html>, no <head>. It is inserted into a page that already has all of that.

Don't open nav.html on its own — it is not meant to work by itself. Contact goes to about.html#contact: a page, and a place on it.

Step 2 · the footer, the same way

<p>Built by Li Wei · Web Technologies 2026</p>

<address>
  <a href="mailto:liwei@example.com">liwei@example.com</a>
</address>

No <footer> tag inside it — every page already has <footer id="site-footer">, exactly as nav.html has no <header>.

<address> means contact details for this page — not any postal address that happens to be in your text.

Step 3 · the script that puts them in

// nav.js — puts the nav and footer into every page
function load(file, target) {
  fetch(file)
    .then(r => r.text())
    .then(html => {
      document.getElementById(target).innerHTML = html;
    });
}

load('nav.html', 'site-header');
load('footer.html', 'site-footer');
fetch(file)go and get that file
.text()read it as text
innerHTMLput it inside the element with that id
function loadwritten once, called twice — DRY in your JavaScript too

Add a fifth page and you edit one file: nav.html. That is a component.

One thing will go wrong — and it is the useful part

Opened with file://, the nav is missing.

fetch needs a server.

Not a bug in your code. A browser security rule: a page opened from your disk may not read other files from your disk. The console says CORS.

The fix: right-click index.html → Open with Live Server. The address bar says http://127.0.0.1:5500 — and the nav appears.

Imagine if it could: a page you opened from an email could read anything in your home folder.

Before you call it done

Check it like a stranger would.

Validate the pages, not the fragments. nav.html is not a page, so on its own it will fail.

When it does not work · find the layer first

You seeThe causeLook at
no nav, no footeropened with file://the address bar → Open with Live Server
nav missing on one pageno id="site-header", or no <script>compare it with a page that works
no styling at allthe stylesheet href does not match the filestyle.css — spelling and capitals
中文 shows as ���no charset<meta charset="UTF-8">
tiny page on a phoneno viewportthe viewport <meta>
a broken imagewrong path or capitalsDevTools → Network → the red 404
a CSS rule is ignoreda more specific rule winsDevTools → Styles → the struck-through rule

Capitals work on your laptop and break on a server: Windows and macOS ignore them, the Linux server does not.

Recap · done

What you should be able to say now.

You can build it by hand — so now you can judge what an AI builds.

Part 6 · from now on

Now you can use AI.

In VS Code, on your own site. You wrote every line by hand first — that is what lets you judge what it writes.

The loop · one change at a time

Commit→Ask→ Read→Test→Keep or undo

Cannot explain a line? Ask the AI to explain it — or undo it. Work you cannot explain does not pass.

Say what you want — precisely

✗ Vague

make my website look better

It will guess — and rewrite things you never asked it to touch.

✓ Precise

In style.css, show the .quote articles on quotes.html in a grid: two columns on screens wider than 800px, one column on phones. Do not change any HTML. Explain every property you add.

What, where, what not to touch — and an explanation.

A vague prompt gets a pile of <div>s that looks fine and means nothing. You now know the difference.

After every change · check it the way you checked your own

The AI writes fast. Your job is the part it cannot do: knowing whether it is right.

Your task

Make it yours — with AI, one change at a time.

Design

  • colours and a font that fit your site
  • the quotes as cards in a grid
  • right on a phone, not only on a laptop
  • a hero image that is really yours

Features

  • a like button on each quote
  • a "random quote" button
  • the current page marked in the nav
  • quotes filtered by language
Add a like button to each quote on quotes.html. Use a <button>, not a <div>. Put the JavaScript in a new file, likes.js. The count may reset when the page reloads. Explain the code line by line.

One change. Read it. Test it. Commit it. · webtech.landrock.io/sessions

← → navigate · F fullscreen · P print · Copy never turns the page