The booking form is the most important piece of The Blue Cup: it is where three of the plan's four objectives are met. And yet it is the one carrying the most pending items. You built it in Module 5 with everything you knew about forms, in Module 8 you gave it some basic styles and in Module 10 you associated its hints with aria-describedby, but it still lacks its final design, it only offers the bread-making workshop and it sends the data to a fictitious address, forms.thebluecup.example. In this lesson you will close all those fronts. You will reorganise the form for the two workshops, give it its final styles (focus, validation states with :user-invalid, visible and associated error messages, checkboxes and buttons), make the links in workshops.html go straight to the choice of workshop with the simplest possible solution, connect it to a real form service, add a honeypot field against spam and create the thanks.html confirmation page following the POST/Redirect/GET pattern. You will finish by testing the complete journey, from the workshop card to the email the café receives, with a checklist of your own for forms.

Contents

  1. The starting point and what's missing
  2. Reorganising the form for the workshops
  3. The final styles of the form
  4. From the workshop to the form: preselecting the booking type
  5. Connecting to a real form service
  6. The honeypot field against spam
  7. The thanks.html confirmation page
  8. Testing the complete flow
  9. The site's other forms
  10. Form checklist
  11. Project: the final bookings.html and thanks.html

The starting point and what's missing

Review the state of bookings.html against the pending items and the personas in the plan:

Aspect State at the end of Module 10 What's missing Pending item or persona
Booking types Table or bread-making workshop Add the latte art workshop Sarah, objective O3
Order First "Your details", then "Your booking" Start with what is being booked Sarah, Anthony
Styles The basic ones from Module 8, no error states Focus, visible errors, comfortable checkboxes P4; Anthony (zoom), Lucy (mobile)
Hints Phone, time, guests and comments Hints for email, name and date Mark (screen reader)
Submission Fictitious URL Real service, anti-spam, confirmation P3
Dates min="2026-12-01", max="2027-03-31" Review P8

You know everything you are going to use: fieldset and legend (Labels and Grouping), validation attributes (Form Attributes and Validation), method, action, PRG, third-party services and the GDPR (Submitting Forms), aria-describedby (Using ARIA Roles and Attributes). The lesson focuses on integrating those pieces.

Reorganising the form for the workshops

First, what is being booked

Until now the form asked for personal details first. But people who arrive from the workshops page already know what they want to book, and that determines the rest (the date, the time, whether the area makes sense). The logical order is: what → when → who → preferences. Move the "Your booking" fieldset in front of "Your details". It's a change of order in the HTML, and the order of the HTML is the reading and tabbing order (Web Accessibility Basics): nothing else needs touching.

Three options instead of two

The radio button group now has three values. As the labels are long, each option goes in its own container, one below the other:

        <fieldset id="book-workshop">
          <legend>What would you like to book? *</legend>
          <div class="option">
            <input type="radio" id="type-table" name="type" value="table" checked required>
            <label for="type-table">A table</label>
          </div>
          <div class="option">
            <input type="radio" id="type-bread-workshop" name="type" value="bread-workshop" required>
            <label for="type-bread-workshop">A place on the sourdough bread-making workshop (first Saturday of every month, 10:00–13:00)</label>
          </div>
          <div class="option">
            <input type="radio" id="type-latte-art-workshop" name="type" value="latte-art-workshop" required>
            <label for="type-latte-art-workshop">A place on the latte art workshop (second Thursday of every month, 18:00–20:00)</label>
          </div>
        </fieldset>
  • The values change: workshop becomes bread-workshop, and latte-art-workshop appears. Remember that the name and value attributes are a contract with whoever receives the data (Submitting Forms): as you're going to start using a new service in this very lesson, now is the time to change it. If the form were already in production, you would have to let whoever processes the bookings know.
  • div.option is a layout container with no meaning: the fieldset and the legend already provide the semantic grouping.
  • The id="book-workshop" on the fieldset will be the destination of the workshop links (you'll see this in the section on preselection).
  • required on the group and checked on "A table": the group is never left empty. For people coming from a workshop, the table is ticked by default; you'll solve this with preselection.

Hints for every required field

In Using ARIA Roles and Attributes you associated the hints that already existed. Now add the missing ones, because in the next section the hints will also serve as error messages:

Field New hint (small with id)
Name help-name: "As you'd like it to appear on the booking."
Email help-email: "We'll send your confirmation here."
Date help-date: "For a workshop, choose one of its dates: first Saturday (bread) or second Thursday (latte art)."
Time help-time, extended: "From 8:00 to 19:00, on the hour or half past. For a workshop, give its start time."

Each field links its hint with aria-describedby, like the others.

The dates (pending item P8)

The comment "Update min and max periodically" was put there for this. With the site about to be published at the beginning of December 2026, the values min="2026-12-01" and max="2027-03-31" match the workshop calendar: they stay. What changes is that there is now a recurring task in the plan: every quarter, when the new workshop dates are published, update min and max too. Remember that these limits only help the person filling in the form; the real check (date not in the past, the right day for the workshop, places available) is done by whoever receives the booking.

The final styles of the form

Section 8 of styles.css already gives the fields their basic look. Four things are missing: clearly visible focus on every control, comfortable checkboxes and radio buttons, the error states and the highlighting of the group when arriving from a workshop.

  1. A variable for the error colour (section 1)

  /* States */
  --color-error: #b3261e;

A dark red with a contrast of 6.5:1 on white: it exceeds the 4.5:1 required for normal text (Web Accessibility Basics). Measure it with your contrast tool before using it; never choose an error colour "by eye".

  1. Checkboxes and radio buttons (section 8)

input[type="radio"],
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0 0.5rem 0 0;
  vertical-align: middle;
  accent-color: var(--color-brand);
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.option input {
  flex-shrink: 0;
  margin-top: 0.2rem;
}
  • width and height of 1.25rem (20 pixels): native controls are tiny (about 13 pixels). Together with the label, which can also be clicked, the touch target is comfortable for Lucy on her mobile. WCAG 2.2 requires a minimum size of 24 × 24 pixels or enough spacing between targets (criterion 2.5.8, level AA); with the clickable label and the margin between options, it is met.
  • accent-color paints the native control in the brand blue without rebuilding it: it still works with the keyboard and the screen reader. It's the modern way to customise checkboxes without tricks.
  • .option as a flex row: the control on the left and the label on the right; if the label takes up two lines (as on mobile), the second line stays aligned with the text, not below the circle.
  • flex-shrink: 0: the control never shrinks, however long the label is.

  1. Focus

The :focus-visible rule in section 2 already draws an outline on any element focused with the keyboard. For text fields, section 8 also had a change of border colour with :focus. Check it with the keyboard: press Tab through the whole form and check that every control, including the checkboxes and radio buttons, shows the outline. If in some browser the outline of the checkboxes sits right up against the control, separate it:

input[type="radio"]:focus-visible,
input[type="checkbox"]:focus-visible {
  outline-offset: 3px;
}

  1. Error states: :user-invalid

In Form Attributes and Validation you came across :invalid. Its problem is that it applies from the moment the page loads: an empty required field is already invalid before the person touches it, and painting the whole form red as soon as they arrive is unpleasant and confusing. The :user-invalid pseudo-class solves that: it only applies when the field is invalid and the person has already interacted with it (they have changed it and left it, or they have tried to submit the form).

Pseudo-class Applies when… Use
:invalid The value doesn't meet the constraints, at any time Almost never for visible styles
:user-invalid The value doesn't meet the constraints after the person has interacted Error styles
:valid / :user-valid The equivalents for correct values In moderation: a form full of green ticks is distracting
/* Error states: only after the person has interacted */

input:user-invalid,
select:user-invalid,
textarea:user-invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 1px var(--color-error);
}

input[type="radio"]:user-invalid,
input[type="checkbox"]:user-invalid {
  outline: 2px solid var(--color-error);
  outline-offset: 2px;
}

p:has(> :user-invalid) small {
  color: var(--color-error);
}

p:has(> :user-invalid) small::before {
  content: "Check this field. ";
  font-weight: bold;
}

Explanation, rule by rule:

  • The field's border turns red and is visually thickened with a 1-pixel shadow. box-shadow is used instead of increasing the border because the shadow takes up no space: the field doesn't change size and nothing moves (the same principle as CLS in Performance and Resource Loading).
  • Checkboxes and radio buttons have no customisable border: they are marked with a red outline.
  • p:has(> :user-invalid) small: "the small in a paragraph that contains a direct child in an error state". The :has() pseudo-class lets you style an element according to what it contains; here, the hint for a field with an error, which is in the same paragraph. The hint turns red.
  • ::before with "Check this field.": adds text in front of the hint. That way the error doesn't depend on colour alone (Web Accessibility Basics): someone who can't distinguish red reads the word "Check".

Why these messages are "visible and associated"

  • Visible: they appear next to the field, as text, and remain as long as the error exists. The browser's native messages (the bubbles that appear on submission) disappear after a few seconds and only show the first error.
  • Associated: the hint was already linked to the field with aria-describedby. On returning to the field, the screen reader reads the label, the state ("invalid", which the browser exposes by itself for fields that don't meet their constraints) and the description, which now begins with "Check this field". Text generated with ::before is part of the text that assistive technologies read.
  • Explanatory: the hint says how to correct the error ("9-digit Spanish phone number…"), not just that there is an error.

Bear in mind the limits of this solution without JavaScript: the message is the same for any error in the field (empty or mistyped), and when submitting with errors the focus goes to the first invalid field, which is what the browser does by default. A custom error system (an error summary at the top, different messages depending on the problem, aria-invalid managed by hand) requires JavaScript and is beyond the scope of this course. For The Blue Cup, the combination of native validation, :user-invalid and associated hints is solid and accessible.

Compatibility. :user-invalid and :has() work in the current versions of all the major browsers. In an old browser, these rules simply aren't applied: the form still works with the native messages. This is progressive enhancement: the basics work everywhere and the extras wherever possible.

  1. The buttons

The buttons have had two variants since Styling HTML Elements: the primary one (blue, "Send booking") and the secondary type="button" (white, "Booking conditions"). All that's left is for the submit button to stand out as the final action of the form:

form button[type="submit"] {
  width: 100%;
  max-width: 24rem;
  padding: 0.9em 1.25em;
  font-size: 1.1rem;
}

On mobile it takes up the full width, like the fields, and is easy to tap; on wide screens it is limited to the width of the fields.

From the workshop to the form: preselecting the booking type

Sarah clicks "Book a place on the latte art workshop" in workshops.html. Ideally, she would arrive at the form with that option already selected. How can that be done? There are three possibilities:

Solution Link in workshops.html Does it select the option? Requirements
A. Plain link bookings.html No; she arrives at the top of the page Nothing
B. Anchor to the option group bookings.html#book-workshop No, but it takes her straight to the group and highlights it An id and a CSS rule
C. Parameter in the URL bookings.html?type=latte-art-workshop Yes A small script that reads the URL

Why does option C need JavaScript? Because HTML can't read the URL: the browser has no attribute that says "select the radio button whose value matches the type parameter". Something has to read ?type=… and select the option, and on a static site only a script in the browser can do that.

For The Blue Cup, the chosen solution is B, as it is the simplest one that solves the main problem:

  • Without JavaScript, nothing can go wrong.
  • Sarah lands right on the question "What would you like to book?", which, after the reorganisation, is also the first thing in the form, and she sees it highlighted.
  • Selecting the option costs her one tap, with the workshop label in front of her.

In workshops.html, change the two links:

          <p><a class="btn" href="bookings.html#book-workshop">Book a place on the bread-making workshop</a></p>
          <p><a class="btn" href="bookings.html#book-workshop">Book a place on the latte art workshop</a></p>

And in styles.css (section 8), highlight the group when it is the link's destination:

fieldset:target {
  padding: 0.75rem;
  border: 3px solid var(--color-brand);
  background-color: var(--color-cream);
  scroll-margin-top: 1rem;
}
  • :target is the pseudo-class for the element whose id matches the #… part of the URL. It only applies when you arrive with #book-workshop; if you go into bookings.html from the menu, the group looks normal.
  • The highlighting doesn't depend on colour alone: a thick border and a cream background frame the group.
  • scroll-margin-top leaves a small margin above the group when scrolling, so that the legend isn't stuck to the edge of the window.
  • The target group is a nested fieldset, and the fieldset fieldset rule removes its border and padding. Which one wins? Work out the specificity (Basic CSS Selectors): fieldset:target is (0, 1, 1) and fieldset fieldset is (0, 0, 2). fieldset:target wins on specificity, wherever it is in the stylesheet; even so, place it straight after fieldset fieldset so that anyone reading the stylesheet sees the two rules together.

Option C, with a five-line script, is available as an extension in exercise 2. If you decide to use it, it must be an enhancement: the link would also include the anchor, so that without JavaScript it behaves like option B.

Connecting to a real form service

The Blue Cup is a static site: there's no program on the server to receive the data. In Submitting Forms you saw the alternatives; now you have to choose. These are the families of options, with examples of well-known services (terms, prices and limits change frequently: always check them in their current documentation):

Option Examples How it connects Advantages Drawbacks
The hosting's own forms Netlify Forms Attributes on the form; the hosting detects the form on publishing Integrated with deployment; dashboard and email notifications Only works on that hosting
Independent form service Formspree, Basin, Getform The action points to a URL the service gives you Works with any hosting Yet another company processing the data; free plan limits
Your own program on the server PHP, Node.js, Python… on traditional hosting The action points to your program Full control of the data It has to be programmed, secured and maintained
mailto: in the action — — None Unreliable: ruled out since Module 5

The selection criteria, in order of importance for a small business:

  1. Data protection: does it offer a data processing agreement? Where does it store the data? If it's outside the European Economic Area, there are international data transfers that the data protection professional must assess.
  2. Spam protection: honeypot field, filters, verification.
  3. Notifications: the café should receive an email with each booking.
  4. Cost and limits: number of submissions a month on the free plan.
  5. Fit with the hosting you're going to use.

For The Blue Cup, Netlify Forms is chosen, because in Testing and Deployment you will publish the site on Netlify: hosting and forms with a single provider, and a single data processing agreement to review. If you choose another hosting, the natural alternative is an independent service; you'll see the difference in the code in a moment.

The form connected to Netlify Forms

Only the opening tag of the form changes (and the honeypot field is added, in the next section):

      <form name="bookings" action="/thanks.html" method="post"
            data-netlify="true" data-netlify-honeypot="website">
  • name="bookings": the name under which the form will appear in the Netlify dashboard. The name attribute of the form is standard HTML.
  • data-netlify="true": tells Netlify that it must process this form. When publishing, Netlify reads the HTML, detects the form and adds what it needs (a hidden field with its name). As it is a data-* attribute, the validator doesn't give an error (Data Attributes). Netlify also accepts the form netlify with no prefix, but it isn't a valid HTML attribute.
  • data-netlify-honeypot="website": the name of the honeypot field (next section).
  • action="/thanks.html": the page Netlify redirects to after receiving the data. It is the exception to the project's rule of relative paths: Netlify expects a path from the root of the site, starting with /. Note it in a comment in the code, so that nobody "corrects" it.
  • method="post", as always for personal data.

In the Netlify dashboard, before the first deployment with the form, you need to enable form detection for the site and set up an email notification to [email protected] for each submission. You'll do this in Testing and Deployment, along with publication.

With an independent service, on the other hand, the form would look like this (the URL is an example of the format; the service gives you the identifier when you create the form):

      <form action="https://formspree.io/f/IDENTIFIER" method="post">

And the honeypot field and the confirmation page would be configured according to that service's documentation.

The basic data protection information

The basic information paragraph you wrote in Submitting Forms named "the provider that manages our forms" as the recipient. Now you know which one it is: send the data protection professional the name of the service, the link to its data processing agreement and the information about where it stores the data, and replace the paragraph with the text they send back. The same professional will use that information to finalise the full privacy policy (pending item P2).

Don't publish the connected form until you have that text reviewed. A form that sends real personal data to a third party without the correct information breaks the law, however impeccable the code.

The honeypot field against spam

As soon as a form is published, spam bots start filling it in. A honeypot field is a field that people don't see but bots do: bots fill in every field they find in the HTML; if this one arrives with content, the submission is discarded. Netlify does this automatically with the field given in data-netlify-honeypot.

Add it right after the opening of the form:

        <!-- Honeypot field against spam: hidden from people; if it arrives filled in, the submission is discarded -->
        <p class="honeypot-field" aria-hidden="true">
          <label for="website">Don't fill in this field</label>
          <input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
        </p>

And in section 8 of styles.css:

.honeypot-field {
  position: absolute;
  left: -100vw;
}

Each detail stops a person from falling into the trap:

Detail What it prevents
.honeypot-field off the screen It being seen. It is moved off the screen instead of using hidden or display: none because some bots ignore fields hidden in those ways
aria-hidden="true" on the paragraph A screen reader announcing it
tabindex="-1" It being reached with Tab (an element hidden with aria-hidden must never be able to receive focus)
autocomplete="off" The browser filling it in automatically
The label "Don't fill in this field" That, if someone did see it (for example, without CSS), they know what to do
name="website" A plausible name that tempts bots; trap would be too obvious

A honeypot field doesn't stop every bot, but it does stop most automated ones, and it doesn't bother anyone. It is preferable to a visual verification challenge, which adds a barrier for many people.

The thanks.html confirmation page

In Submitting Forms you learnt the POST/Redirect/GET (PRG) pattern: the server receives the POST, processes the data and redirects the browser to a confirmation page, which is requested with GET. That way, if the person reloads the confirmation page, they don't resubmit the booking. With Netlify Forms, the server is Netlify, and the confirmation page is the one you give in the action.

Create thanks.html from template.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Request received | The Blue Cup</title>
    <meta name="description" content="We have received your booking request at The Blue Cup.">
    <meta name="robots" content="noindex">
    <link rel="stylesheet" href="css/styles.css">

    <link rel="icon" href="img/favicon.svg" type="image/svg+xml">
    <link rel="icon" href="img/favicon.png" sizes="32x32" type="image/png">
    <link rel="apple-touch-icon" href="img/apple-touch-icon.png">
    <meta name="theme-color" content="#1f4e79">
  </head>
  <body>
    <a class="skip-link" href="#content">Skip to content</a>
    <header>
      <!-- The template's logo and menu, without aria-current: this page isn't in the menu -->
    </header>

    <main id="content">
      <h1>We have received your booking request</h1>
      <p>Thank you for booking with The Blue Cup. Your booking <strong>is not confirmed yet</strong>: we'll check availability and write to you within 24 hours.</p>

      <h2>What happens now</h2>
      <ol>
        <li>We check whether there's a table or a place available on the date and at the time you've chosen.</li>
        <li>We send you an email from <a href="mailto:[email protected]">[email protected]</a> to confirm the booking or suggest another date.</li>
        <li>If you don't receive it, check your spam folder or call us on <a href="tel:+34900000000">+34&nbsp;900&nbsp;000&nbsp;000</a>.</li>
      </ol>

      <p><a href="workshops.html">See the workshops</a> · <a href="menu.html">See the menu</a> · <a href="index.html">Back to the home page</a></p>
    </main>

    <footer>
      <!-- The template's footer, unchanged -->
    </footer>
  </body>
</html>

The decisions on this page:

  • meta name="robots" content="noindex": the page only makes sense after submitting the form; it mustn't appear in search engines (Metadata).
  • No canonical URL or Open Graph: it isn't going to be shared or indexed. Delete those blocks from the template.
  • The h1 says exactly what has happened: a request has been received. It doesn't say "booking confirmed", because it isn't: the café has to check availability. Promising what the system doesn't guarantee produces customers who turn up without a table.
  • An ordered list with the next steps answers the question everyone asks themselves after submitting a form: "and now what?".
  • Useful exit links, so that the page isn't a dead end (as planned in the review of the overall plan).
  • Full menu, without aria-current, like privacy.html.

Testing the complete flow

This is the complete journey, from the moment Sarah decides to book until the café receives the notification:

sequenceDiagram
    actor S as Sarah
    participant N as Browser
    participant W as Netlify (site and forms)
    participant T as The Blue Cup (email)
    S->>N: Clicks “Book a place on the latte art workshop”
    N->>W: GET /bookings.html (the #book-workshop isn't sent to the server)
    W-->>N: 200 OK: bookings.html
    N->>S: Scrolls the page to the highlighted group
    S->>N: Selects the workshop, fills in the form and clicks “Send booking”
    N->>N: Native validation (required, pattern, min/max…)
    alt There are errors
        N->>S: Native message, focus on the first error, :user-invalid in red
    else Everything is correct
        N->>W: POST /thanks.html with the name=value pairs
        W->>W: Honeypot field filled in? If so, it is discarded
        W->>W: Stores the submission in the dashboard
        W->>T: Notification email with the booking details
        W-->>N: Response that leads to thanks.html
        N->>S: “We have received your booking request”
    end
    T->>S: Confirmation email (sent by a member of staff)

Notice two details in the diagram: the #book-workshop part of the URL never reaches the server (the browser handles it), and the final confirmation is sent by a person at the café: a static site with a form service receives requests; it doesn't manage availability.

What you can test now and what after publishing

With Live Server, the form can't actually be submitted: Live Server doesn't know what to do with a POST, and form detection is only done by Netlify when publishing. Split the tests:

Test When? How
The workshop links lead to the highlighted group Now Click the two links in workshops.html
Validation and error states Now Submit it empty; type an incorrect phone number and leave the field; check the red border and "Check this field."
Keyboard and screen reader Now Go through it with Tab; with NVDA or VoiceOver, listen to the hint of a field with an error
Invisible honeypot field Now It can't be seen, can't be reached with Tab and isn't announced by the screen reader
thanks.html Now Open it directly with Live Server and validate it
Real submission, email notification and redirection After publishing A test booking with fictitious data; check the Netlify dashboard and the DevTools Network tab (Submitting Forms)
The honeypot field in action After publishing In DevTools, fill in the honeypot field by hand and submit: the submission must not appear in the dashboard (or must appear marked as spam)
Reloading thanks.html After publishing Reload: nothing must be resubmitted (PRG)

Note in notes/plan.md the tests pending until publication: you'll do them in the next lesson.

The site's other forms

Review the other three forms with the same criteria:

Form Page Decision
Contact contact.html The same as bookings: name="contact", data-netlify="true", honeypot field and action="/thanks.html". It's acceptable for it to share the confirmation page if its text is made more general; if you prefer, create thanks-contact.html with its own text
Newsletter news.html The same: name="newsletter". Sending the newsletter also requires a bulk email tool with its own privacy assessment: if the business doesn't have one, remove the form before publishing rather than collect email addresses that nobody will use
Search box news.html It points to https://thebluecup.example/search, which doesn't exist: a static site has no search of its own. With six news items, the honest solution is to remove it and, if necessary, add a news index with anchors. A search box that doesn't work is worse than having no search box

This review is another example of an idea from the module: everything that's published must work. A sample form that leads nowhere was acceptable while you were learning; in production it's a mistake.

Form checklist

Add it to your best practices checklist and apply it to every form before publishing it:

Structure

  • [ ] Each field with its associated label; option groups in a fieldset with a legend.
  • [ ] Logical order (what → when → who → preferences); the order of the HTML is the tabbing order.
  • [ ] Required fields marked with * and a note explaining it.
  • [ ] Suitable input types and autocomplete on personal details.

Validation and errors

  • [ ] Constraints with HTML attributes (required, pattern, min, max…), with title on the pattern fields.
  • [ ] A hint associated with aria-describedby on every required field.
  • [ ] Errors with :user-invalid: visible, as text (not only colour), next to the field.
  • [ ] Date min and max up to date.

Submission

  • [ ] method="post" for personal data; the real service's action.
  • [ ] Data processing agreement reviewed; basic data protection information drafted or reviewed by a professional, with a link to the policy.
  • [ ] Honeypot field invisible, without focus, hidden from screen readers.
  • [ ] Confirmation page (PRG) with noindex, which doesn't promise more than the system guarantees.
  • [ ] Email notification to the business set up.

Testing

  • [ ] Complete journey with the keyboard and with a screen reader.
  • [ ] Real test submission after publishing; check in the dashboard and in the Network tab.
  • [ ] Test of the honeypot field and of reloading the confirmation page.

Project: the final bookings.html and thanks.html

  1. The main of bookings.html

This is the complete content of the main in its final version. The skip link, the header (with "Bookings" marked with aria-current) and the footer don't change.

    <main id="content">
      <h1>Book a table or a workshop place</h1>
      <p>Book a table for breakfast, the lunch menu or afternoon tea, or a place on one of our <a href="workshops.html">workshops</a>. We'll confirm your booking by email within 24 hours.</p>
      <p>Fields marked with * are required.</p>
      <p><button type="button" id="open-conditions">Booking conditions</button></p>

      <!-- action with a path from the root: required by Netlify Forms (confirmation page) -->
      <form name="bookings" action="/thanks.html" method="post"
            data-netlify="true" data-netlify-honeypot="website">
        <input type="hidden" name="form" value="web-booking">

        <!-- Honeypot field against spam: hidden from people; if it arrives filled in, the submission is discarded -->
        <p class="honeypot-field" aria-hidden="true">
          <label for="website">Don't fill in this field</label>
          <input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
        </p>

        <fieldset>
          <legend>Your booking</legend>
          <fieldset id="book-workshop">
            <legend>What would you like to book? *</legend>
            <div class="option">
              <input type="radio" id="type-table" name="type" value="table" checked required>
              <label for="type-table">A table</label>
            </div>
            <div class="option">
              <input type="radio" id="type-bread-workshop" name="type" value="bread-workshop" required>
              <label for="type-bread-workshop">A place on the sourdough bread-making workshop (first Saturday of every month, 10:00–13:00)</label>
            </div>
            <div class="option">
              <input type="radio" id="type-latte-art-workshop" name="type" value="latte-art-workshop" required>
              <label for="type-latte-art-workshop">A place on the latte art workshop (second Thursday of every month, 18:00–20:00)</label>
            </div>
          </fieldset>
          <p>
            <!-- Update min and max every quarter, with the workshop calendar -->
            <label for="date">Date *</label>
            <input type="date" id="date" name="date" required min="2026-12-01" max="2027-03-31"
                   aria-describedby="help-date">
            <small id="help-date">For a workshop, choose one of its dates: first Saturday (bread) or second Thursday (latte art).</small>
          </p>
          <p>
            <label for="time">Time *</label>
            <input type="time" id="time" name="time" required min="08:00" max="19:00" step="1800"
                   aria-describedby="help-time">
            <small id="help-time">From 8:00 to 19:00, on the hour or half past. For a workshop, give its start time.</small>
          </p>
          <p>
            <label for="guests">Number of guests *</label>
            <input type="number" id="guests" name="guests" required min="1" max="12" step="1" value="2"
                   aria-describedby="help-guests">
            <small id="help-guests">Up to 12 people. For larger groups, call us on <a href="tel:+34900000000">+34&nbsp;900&nbsp;000&nbsp;000</a>.</small>
          </p>
          <p>
            <label for="occasion">Are you celebrating anything? (optional)</label>
            <input type="text" id="occasion" name="occasion" list="occasions" maxlength="40">
            <datalist id="occasions">
              <option value="Birthday">
              <option value="Anniversary">
              <option value="Farewell party">
              <option value="Work meeting">
              <option value="Christening or first communion">
            </datalist>
          </p>
        </fieldset>

        <fieldset>
          <legend>Your details</legend>
          <p>
            <label for="name">Name *</label>
            <input type="text" id="name" name="name" required minlength="2" maxlength="60" autocomplete="name"
                   aria-describedby="help-name">
            <small id="help-name">As you'd like it to appear on the booking.</small>
          </p>
          <p>
            <label for="email">Email *</label>
            <input type="email" id="email" name="email" required maxlength="100" autocomplete="email"
                   aria-describedby="help-email">
            <small id="help-email">We'll send your confirmation here.</small>
          </p>
          <p>
            <label for="phone">Phone *</label>
            <input type="tel" id="phone" name="phone" required
                   pattern="(\+34 ?)?[6-9]( ?[0-9]){8}"
                   title="9-digit Spanish phone number, with or without +34"
                   placeholder="600 000 000" autocomplete="tel"
                   aria-describedby="help-phone">
            <small id="help-phone">9-digit Spanish phone number, with or without +34 and with or without spaces.</small>
          </p>
        </fieldset>

        <fieldset>
          <legend>Preferences</legend>
          <fieldset>
            <legend>Area (table bookings only)</legend>
            <div class="option">
              <input type="radio" id="area-indoor" name="area" value="indoor" checked>
              <label for="area-indoor">Indoors</label>
            </div>
            <div class="option">
              <input type="radio" id="area-terrace" name="area" value="terrace">
              <label for="area-terrace">Terrace</label>
            </div>
          </fieldset>
          <p>
            <label for="comments">Comments (allergies, highchairs…)</label>
            <textarea id="comments" name="comments" rows="4" cols="40" maxlength="500"
                      aria-describedby="help-comments"></textarea>
            <small id="help-comments">500 characters maximum. If you tell us about any allergies or intolerances, we will only use that information to prepare for your visit.</small>
          </p>
        </fieldset>

        <!-- Text awaiting professional review with the form service details -->
        <p><small><strong>Basic data protection information.</strong>
          [Text reviewed by the data protection professional]
          Further information in our <a href="privacy.html">privacy policy</a>.</small></p>

        <p>
          <input type="checkbox" id="privacy" name="privacy" value="accept" required>
          <label for="privacy">I have read the data protection information *</label>
        </p>

        <p>
          <button type="submit">Send booking</button>
        </p>
      </form>

      <dialog id="conditions" aria-labelledby="conditions-title">
        <h2 id="conditions-title">Booking conditions</h2>
        <ul>
          <li>We hold your table for 15 minutes.</li>
          <li>If you can't come, let us know by phone or email.</li>
          <li>Places on the workshops are limited: 15 on the bread-making workshop and 8 on the latte art workshop.</li>
        </ul>
        <form method="dialog">
          <button>Got it</button>
        </form>
      </dialog>
    </main>

In addition to the main:

  • The title becomes "Table and workshop bookings | The Blue Cup", consistent with the new h1; and the meta description mentions the workshops.
  • The data protection paragraph has a visible marker in square brackets until the text is received: that way it's impossible to publish it by mistake without anyone noticing. Search for [Text reviewed before publishing.

  1. Checking it

  1. Validate bookings.html and thanks.html with the Nu Html Checker: zero errors. The data-netlify and data-netlify-honeypot attributes are valid because they are data-* attributes.
  2. From workshops.html, click the two booking links: you land on the "What would you like to book?" group, highlighted in cream with a blue border.
  3. Submit the form empty: the browser shows its message on the first required field and the fields you've touched are marked in red with "Check this field.".
  4. Type "123" in the phone field and leave it: red border and the hint in red. Correct it: it goes back to its normal appearance.
  5. Go through everything with Tab: the honeypot field never receives focus.
  6. Open thanks.html: it validates, none of the menu links is marked and its links work.
  7. Check the form at 320 px: the long workshop labels wrap onto several lines aligned with the text, and the submit button takes up the full width.

Project status after the lesson

File Changes
bookings.html Final version: "Your booking" first, three booking types, hints on every required field, connection to Netlify Forms, honeypot field, updated conditions; data protection text awaiting review
thanks.html New: confirmation page with noindex
workshops.html Booking links to bookings.html#book-workshop
contact.html Form connected to Netlify Forms with a honeypot field
news.html Search box removed; newsletter connected or removed according to the business's decision
css/styles.css --color-error variable; section 8: checkboxes and radio buttons, .option, checkbox focus, :user-invalid states, submit button, fieldset:target, .honeypot-field
notes/plan.md P3 and P4 resolved (pending a real submission test after publishing); P8 turned into a quarterly task

Common Mistakes and Tips

  • Using :invalid for error styles. The form appears in red before anyone has typed anything. Use :user-invalid.
  • Errors indicated by colour alone. Add text ("Check this field") or an icon with a text alternative.
  • Simply hiding the honeypot field with hidden. It works for people, but some bots ignore fields hidden that way. Move it off the screen, take it out of the tabbing order and hide it from screen readers.
  • Changing name or value without telling whoever receives the data. Bookings would arrive with empty fields or unknown values.
  • A confirmation that promises too much. "Booking confirmed" when only a request has been received causes real problems at the café.
  • Testing submission only locally. Live Server doesn't process forms: the real test is done on the published site, with fictitious data.
  • Leaving decorative forms. A search box or a newsletter that leads nowhere must be removed before publishing.
  • Choosing the service on price alone. The first thing is where and how it processes your customers' data.
  • Tip: ask someone who doesn't know the site to make a booking while you watch in silence. Every time they hesitate, you've found an improvement.

Exercises

Exercise 1. This form fragment has several accessibility and user experience problems. Identify them and write the corrected version with the conventions from the lesson.

<style>
  input:invalid { border: 3px solid red; }
</style>
<input type="email" name="email" placeholder="Email *" required>
<span style="color:red">Invalid email</span>
<input type="text" name="email2" style="display:none">

Exercise 2 (JavaScript extension). Implement preselection option C as a progressive enhancement: the links in workshops.html will include a ?type= parameter and the #book-workshop anchor; a script in js/preselect.js will select the corresponding option if it exists. Write the links, the script and how it is loaded in bookings.html.

Exercise 3 (your own project). Choose your project's main form. Apply the lesson's checklist to it and write: a table comparing two specific form services against the five criteria from the lesson (check their documentation), the form tag connected to the one you choose, the honeypot field and the confirmation page.

Solutions

Solution 1. Problems:

  1. The placeholder acts as the label: it disappears when you type and it isn't a label (Labels and Grouping).
  2. :invalid paints the field red as soon as the page loads.
  3. The error message is always visible, even when there's no error, and it isn't associated with the field.
  4. Inline styles and a <style> block, against the project convention.
  5. The error colour is red, chosen by eye, with no contrast check.
  6. autocomplete="email" is missing.
  7. The honeypot field is hidden with display: none and its name, email2, can confuse password managers and whoever reviews the data.
<p>
  <label for="email">Email *</label>
  <input type="email" id="email" name="email" required autocomplete="email"
         aria-describedby="help-email">
  <small id="help-email">We'll send your confirmation here.</small>
</p>
<p class="honeypot-field" aria-hidden="true">
  <label for="website">Don't fill in this field</label>
  <input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
</p>

And the styles, in styles.css, with the :user-invalid, p:has(> :user-invalid) small and .honeypot-field rules from the lesson, using var(--color-error).

Solution 2.

Links in workshops.html (the parameter goes before the anchor, always in that order):

<p><a class="btn" href="bookings.html?type=bread-workshop#book-workshop">Book a place on the bread-making workshop</a></p>
<p><a class="btn" href="bookings.html?type=latte-art-workshop#book-workshop">Book a place on the latte art workshop</a></p>

The js/preselect.js file:

// Selects the booking type given in ?type= in the URL (bookings.html)
const type = new URLSearchParams(location.search).get("type");
const option = type ? document.getElementById("type-" + type) : null;
if (option && option.name === "type") {
  option.checked = true;
}
  • location.search is the ?type=latte-art-workshop part of the URL; URLSearchParams breaks it down and get("type") returns "latte-art-workshop", or null if there's no parameter.
  • The radio button is looked up by its id (type-latte-art-workshop). If the parameter carries a made-up value, getElementById returns null and nothing happens.
  • The check option.name === "type" prevents a malicious or wrong value from selecting another element that happens to have an id beginning with type-.

In the head of bookings.html, after conditions.js:

    <script src="js/preselect.js" defer></script>

With defer, the script runs when the form already exists (Performance and Resource Loading). Without JavaScript, or if the script fails, the link still leads to the highlighted group thanks to the anchor: the page works just as it does with option B. The static server ignores the ?type= parameter and simply delivers bookings.html.

Solution 3. Open answer. Check that:

  • The table compares the services on data protection (data processing agreement, data location), anti-spam, notifications, cost and fit with your hosting, citing their documentation.
  • The form uses method="post" and the action or the attributes the chosen service specifies, with no errors in the validator.
  • The honeypot field is off the screen, with aria-hidden="true" on its container, tabindex="-1" and autocomplete="off".
  • The confirmation page has noindex, says precisely what has happened and what will happen next, and offers exit links.
  • You have marked the data protection text as awaiting professional review.

Conclusion

In this lesson you have finished the central piece of The Blue Cup. You have reorganised the booking form to start with what is being booked and to offer both workshops, and you have completed its hints. You have given it its final styles: comfortable checkboxes and radio buttons with accent-color, visible focus on every control, errors that only appear after interaction thanks to :user-invalid, messages that are visible, in text and associated with aria-describedby, and a submit button that stands out. You have solved preselection from the workshops with the simplest solution, an anchor with :target, and you have seen why a parameter in the URL requires JavaScript. You have compared the options for processing forms on a static site, connected the form to Netlify Forms, added a honeypot field that only bots see and created thanks.html following the PRG pattern, with a message that doesn't promise more than the system guarantees. You have gone through the complete flow in a sequence diagram, reviewed the site's other forms, removing those that wouldn't work, and you now have a form checklist for any project. But several tests can only be done with the site on the internet, and the site still lives on your computer. In the next and final lesson, Testing and Deployment, you will run the final battery of tests, prepare The Blue Cup for production, publish it on Netlify with HTTPS, check that everything works on the real server and get its maintenance ready.

HTML Course

Module 1: Introduction to HTML

Module 2: Text Formatting in HTML

Module 3: Links and Media in HTML

Module 4: Tables in HTML

Module 5: Forms in HTML

Module 6: HTML5 Semantic Elements

Module 7: Advanced HTML Techniques

Module 8: Integrating HTML and CSS

Module 9: Responsive Web Design

Module 10: Best Practices and Accessibility

Module 11: Project: Building a Complete Website

© Copyright 2026. All rights reserved