Lawfare Academy

CS 220 — Web Applications, SQL and Software Engineering · Weeks 1–2

The web request, semantic HTML and accessibility

Full teaching sequence and cumulative subject work

Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study MDN Getting Started and Core modules: web standards, semantic HTML, forms, CSS layout and accessibility. Complete CS50 Web HTML/CSS and Git. Complete the corresponding source exercises.

Exercise a real HTTP route and its database boundary — primary material, constructed-response tasks, complete worked model and changed-case examination →

HTTP is a trust boundary, not a form submission guarantee

A browser form is a client convenience. A caller can send a request without using that form, alter hidden fields or repeat a submission. The server must establish identity, permission and domain validity independently. Distinguish malformed input, unauthenticated requests, unauthorized object access and conflicts; they require different handling even if all must avoid exposing private details.

Accessibility is also part of the interface contract. A visual caption is not necessarily a programmatic label. Associate labels and controls, identify errors in text, and preserve usable focus after errors. Client validation can improve that experience while server validation remains authoritative.

Worked problem

An order form contains a hidden owner_id and min=0 on hours. A signed-in customer changes owner_id to another customer and sends hours=−3. Design the acceptance boundary.

Trace the complete reasoning
  1. Resolve the customer from a verified server session. Do not adopt the body owner_id as authority.

  2. Validate hours against the server’s type and range contract. A client-side minimum cannot establish that this request satisfies it.

  3. Reject the request before inserting a row. Return an understandable error without revealing another customer’s records.

  4. On the form, connect the error to the hours control and retain the submitted non-sensitive values. Test a raw HTTP request as well as the browser path.

Independent transfer problem

A valid request is repeated after the browser loses the response. Explain how to avoid accidentally creating two orders while preserving a legitimate second order.

Compare the transfer solution

Use a stable submission identifier with a uniqueness constraint and a stored payload fingerprint. An identical retry returns the original result. A conflicting payload under the same identifier is rejected. A legitimate new order receives a new identifier. Disabling the submit button alone cannot protect against network retries or multiple clients.

Learning objectives

  • Explain and trace the mechanisms in the web request, semantic html and accessibility.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

Study the mechanism

A web application crosses a network boundary. A browser sends a request; a server responds with a status, headers and a representation. HTML gives content semantic structure, CSS controls presentation and JavaScript adds behavior. A polished appearance does not establish that the underlying form is accessible or that its data is trustworthy.

Start from native elements. A button expresses an action, an anchor expresses navigation and a label associates a form control with its name. Replacing a button with a clickable div requires rebuilding keyboard and accessibility behavior that the native element already provides. Heading order should reflect document structure rather than font size. A user should understand a control without relying only on color, position or a mouse.

Browser validation improves feedback but does not protect the server. A client can bypass a form entirely and send a request directly. Validate submitted data again at the server boundary, including type, length, allowed values and relationships. Preserve entered values after an error where appropriate and identify the specific field needing correction. Test keyboard navigation, narrow screens and error states rather than only a successful desktop screenshot.

Worked example

<form method="post" action="/orders">
  <label for="description">Work description</label>
  <input id="description" name="description" maxlength="120" required>
  <label for="hours">Whole hours</label>
  <input id="hours" name="hours" type="number" min="0" step="1" required>
  <button type="submit">Create work order</button>
</form>

The labels are explicitly connected to inputs by matching for and id attributes. Names determine submitted field names. min and step describe client constraints, but the server must still reject negative or fractional hours and overlong descriptions. This form is a markup example; it requires an implemented POST /orders handler before it can save anything.

Check your understanding

What protects the server from a bypassed form?

  1. Server-side validation and authorization
  2. The required attribute alone
  3. A green submit button
Answer and reasoning for every option

Correct: Server-side validation and authorization Client controls are useful feedback but are not a trust boundary.

Reconsider: The required attribute alone A custom HTTP client can omit browser validation.

Reconsider: A green submit button Color communicates no server-side guarantee.

Transfer laboratory: A form succeeds visually but saves nothing

The browser shows a success banner immediately after a click, before the POST finishes. The server later rejects the request. Design correct observable states.

Work through the full solution

Use submitting, saved and failed states tied to the actual response. Disable or otherwise control duplicate actions while pending, but allow recovery. Show success only after the server confirms persistence. Retain safe entered data after validation errors and associate each error with its field. Test a slow success, HTTP rejection and dropped connection separately.

Evidence of understanding

The UI cannot claim saved state before confirmation and must support an explicit retry path.

Complete on-site teaching readings

These are full attributed source sections, not previews. Read them alongside the original Academy explanation and code.

  1. How the web works · Mozilla Contributors
  2. Basic HTML syntax · Mozilla Contributors
  3. Structuring documents · Mozilla Contributors
  4. Forms and buttons in HTML · Mozilla Contributors
  5. Responsive web design · Mozilla Contributors
  6. HTML: A good basis for accessibility · Mozilla Contributors

Open in My Learning to record progress →