Skip to content
KALANBLON
Show contents

Chapter 6 of 7 · 25 min

Project: your personal page

By the end of this chapter, you'll be able to

  • Plan a page from its content before writing the code
  • Bring semantic HTML, a form, Flexbox and Grid together in one page
  • Check a page with an accessibility and mobile checklist
  • Make a page light for slow connections

Step 1: content first

Before writing a single tag, list what the page must say. The code then comes to dress that content.

  1. Who you are: name, an introductory sentence, a photo (optional).
  2. What you can do: three to six skills or achievements, as cards.
  3. How to contact you: a small form and an e-mail link.

The HTML outline follows directly: a <header> with your name and a menu, a <main> with three <section>s (introduction, work, contact) and a <footer>.

After the fix, the page passes the whole checklist.

Step 6 of 6
Text description of the animation
  1. We list the contents: that's the page's outline.
  2. The HTML follows this outline. At this stage, without CSS, the page must already read well in order.
  3. We style for a phone first: one column, comfortable spacing.
  4. We add the two-column introduction and the work grid for big screens.
  5. The check finds a problem: with the keyboard, you can't see where you are.
  6. After the fix, the page passes the whole checklist.

Step 2: the HTML

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Nadia Benali — Web developer</title>
  <meta name="description" content="Web developer in Casablanca: accessible, fast websites.">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <a class="skip" href="#content">Skip to content</a>
  <header class="top">
    <p class="name">Nadia Benali</p>
    <nav aria-label="Main menu">
      <ul class="menu">
        <li><a href="#work">Work</a></li>
        <li><a href="#contact">Contact</a></li>
      </ul>
    </nav>
  </header>

  <main id="content">
    <section class="intro">
      <img src="nadia.webp" alt="Nadia smiling in front of her computer" width="320" height="320">
      <div>
        <h1>I build fast, accessible websites</h1>
        <p>A web developer in Casablanca, I help associations and small shops get noticed online.</p>
      </div>
    </section>

    <section id="work">
      <h2>Work</h2>
      <div class="cards">
        <article class="card">
          <h3>Website for an argan cooperative</h3>
          <p>A catalogue that reads well on mobile and loads in under 2 seconds on 3G.</p>
        </article>
        <article class="card">
          <h3>Sign-up form for a football club</h3>
          <p>Validated by the browser, usable with the keyboard.</p>
        </article>
        <article class="card">
          <h3>Page for a music festival</h3>
          <p>A programme laid out in a grid, from the phone to the giant screen.</p>
        </article>
      </div>
    </section>

    <section id="contact">
      <h2>Contact</h2>
      <form action="/contact" method="post" class="form">
        <label for="c-name">Your name</label>
        <input id="c-name" name="name" type="text" autocomplete="name" required>
        <label for="c-email">Your e-mail</label>
        <input id="c-email" name="email" type="email" autocomplete="email" required>
        <label for="c-message">Your message</label>
        <textarea id="c-message" name="message" rows="5" required></textarea>
        <button type="submit">Send</button>
      </form>
    </section>
  </main>

  <footer><p>© 2026 Nadia Benali</p></footer>
</body>
</html>

A few details that make the difference:

  • lang="en" tells the screen reader the language, so it picks the right pronunciation;
  • <title> and <meta name="description"> show in the tab and in search engine results;
  • the skip link "Skip to content" lets keyboard users jump over the menu. It's hidden until it receives focus;
  • id="work" is the target of the menu's href="#work" link.

Step 3: the CSS, from mobile to big screen

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #0e2240;
  --accent: #b5470f;
  --background: #fdf8f2;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--background);
}

main, .top { max-width: 60rem; margin-inline: auto; padding-inline: 1rem; }

img { max-width: 100%; height: auto; }

.skip { position: absolute; left: -999rem; }
.skip:focus { left: 1rem; top: 1rem; background: white; padding: 0.5rem; }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; }
.menu { display: flex; gap: 1rem; list-style: none; padding: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr));
  gap: 1rem;
}
.card { background: white; border: 1px solid #d5dde6; border-radius: 0.75rem; padding: 1rem; }

.form { display: grid; gap: 0.5rem; max-width: 32rem; }
input, textarea, button { font: inherit; padding: 0.6rem; }
button { background: var(--accent); color: white; border: 0; border-radius: 0.5rem; cursor: pointer; }

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 48rem) {
  .intro { display: grid; grid-template-columns: 1fr 2fr; gap: 2rem; align-items: center; }
}
  • CSS variables (--accent) keep the colours in one place: changing the theme means changing three lines.
  • :focus-visible draws a clearly visible outline around the active element when navigating with the keyboard, without getting in the way of mouse clicks.
  • The introduction switches to two columns beyond 48rem; the work grid adapts on its own.

Step 4: the checklist

Before publishing, check each point:

  1. Keyboard: with the Tab key alone, you reach every link, field and button, in a logical order, and you can always see where you are.
  2. Screen reader: a single <h1>, headings without skipped levels, a label for each field, an alt for each image.
  3. Contrast: the text stands out clearly from its background. The ratio must be at least 4.5:1 for normal text, according to the WCAG rules; the browser's developer tools show it.
  4. Mobile: at 360 pixels wide, no horizontal scrolling, and clickable areas of about 44 pixels at least.
  5. Weight: images in a modern format (webp, avif), at the right size, with width and height. Aim for a complete page of a few hundred kilobytes.

Your turn

Project: your personal pageHTML · CSS

Preview

The preview is isolated from the page and runs no scripts · Ctrl/⌘ + Enter to run · Esc then Tab to leave the editor

Worked exercise

Worked exercise: dark mode

Add an automatic dark mode to the project page: when the user's system is set to dark, the background becomes midnight blue, the text light, and the cards slightly lighter than the background. The text must stay well contrasted. Only change the CSS variables.

Hint 1
The media query @media (prefers-color-scheme: dark) applies when the system is in dark mode.
Hint 2
If the cards use a variable (background: var(--card)) instead of white, you just have to redefine the variables inside the media query.
Show the solution and common mistakes
:root {
  --ink: #0e2240;
  --accent: #b5470f;
  --background: #fdf8f2;
  --card: #ffffff;
  --border: #d5dde6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6eef8;
    --accent: #f5a04f;
    --background: #0b1626;
    --card: #14243a;
    --border: #2c4466;
  }
}

.card { background: var(--card); border: 1px solid var(--border); }

Common mistakes:

  • Keeping the same accent colour as in light mode: dark orange on midnight blue is no longer contrasted enough. We lighten it.
  • Writing colours directly into each rule: everything then has to be duplicated for dark mode, and you're bound to forget some.

Summary

  1. 1Start from the content: the page's outline gives the HTML structure directly.
  2. 2lang, title, meta viewport and meta description are essential in every page.
  3. 3The CSS starts with mobile, then grows with media queries.
  4. 4CSS variables centralise the colours, which makes dark mode very simple.
  5. 5Before publishing: keyboard, screen reader, contrast, 360 pixels and image weight.

Your progress is saved on this device. Create a free account to keep your progress on all your devices.