Documents, layout and HTTP
Original on-site instruction. Practice and outside references are optional. Independent subject review and observed learner testing remain pending.
From an address to a representation
Consider a fictional repair service whose visitor opens `/orders/new`. The browser resolves the host name to a network address, establishes the appropriate connection, and for HTTPS negotiates an encrypted connection with certificate validation. Encryption protects the connection under its security assumptions; it does not establish that the application validates an order. The browser sends an HTTP request with a method, target and headers. The server selects a route and returns a status, headers and a body. A document can trigger additional requests for style sheets, scripts and images. A visible page is therefore the result of several operations, any of which can fail separately.
GET requests retrieve a representation and should not implement a business mutation such as creating an order. A POST can submit a proposed operation, but its method alone supplies neither permission nor exactly-once execution. The earlier duplicate-submission investigation still applies. A URL path identifies a resource or route; a query string supplies parameters; a fragment selects a location inside the retrieved document and is not sent as part of an ordinary HTTP request target. A request for `/orders?status=open#results` sends the path and query, while the browser uses `results` locally as a fragment target.
Distinguish protocol observations from domain conclusions. A 200 response says the HTTP request succeeded according to the server's response, but the application must still define the body contract. A 201 can represent creation, a redirect can lead to a retrieval page, a 400 can report malformed input, a 401 an authentication requirement, a 403 denied access and a 409 a state conflict. These examples are choices within a documented API, not instructions to expose confidential details in an error. A network failure after a POST leaves the caller uncertain: the server might have committed before the response was lost. Retry using the operation identity policy already taught in the native lesson.
Build a document whose structure explains its purpose
HTML describes a document tree. An element usually has a start tag, content and an end tag; attributes configure that element. Nest elements according to their content rules and close them coherently. Browser error recovery can produce a tree different from the indentation you intended. Inspect the resulting document structure rather than treating a forgiving render as proof of correct markup. Void elements such as input do not wrap child content.
The document head contains metadata such as a useful title, character encoding and viewport configuration. The body contains the visible document. Use a main landmark for the principal content, headings for section relationships, paragraphs for prose and lists for parallel items. A heading is not merely a large-font paragraph. A table represents data with row/column relationships and headers; CSS layout, rather than a table of empty cells, should position unrelated page regions. An informative image needs alternative text that serves its role; a decorative image generally needs an empty alternative rather than an invented description.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Request a repair visit</title>
</head>
<body>
<a href="#main">Skip to request form</a>
<main id="main">
<h1>Request a repair visit</h1>
<p id="instructions">Describe the work. This example saves nothing by itself.</p>
<form method="post" action="/orders" aria-describedby="instructions">
<label for="description">Work description</label>
<textarea id="description" name="description" maxlength="120" required></textarea>
<label for="hours">Whole hours</label>
<input id="hours" name="hours" type="number" min="0" step="1" required>
<label for="priority">Preferred scheduling</label>
<select id="priority" name="priority">
<option value="routine">Routine</option>
<option value="review">Request staff review</option>
</select>
<button type="submit">Send request</button>
</form>
</main>
</body>
</html>The explicit labels use the controls' IDs. The names determine the submitted field names; an ID alone does not supply a form-data name. The select submits its selected value, not necessarily the visible explanatory wording. A textarea holds longer text. A radio group can express one choice among alternatives, while checkboxes express independent selections; decide the data contract before choosing a control. Within a form, specify a non-submitting action as `type="button"` so that an incidental button does not unexpectedly submit. Native constraints help a visitor correct input, while the server repeats authoritative validation as the preserved lesson explains.
The HTML example is an inspectable document, not a complete application. Its POST requires an implemented route. A secure session design may also require a CSRF mechanism, taught in the later security preparation. Do not add a hidden owner field and mistake it for identity. Do not display a success message before the actual persistence response. The lesson's original trust-boundary cases supply those application decisions.
CSS selects boxes and resolves competing declarations
A CSS rule associates a selector with declarations. `label { display:block; }` selects label elements. `.request-panel` selects elements carrying that class, and `#main` selects an ID. A descendant selector expresses ancestry, not adjacency in the source file. Several declarations can apply to one property. The cascade considers origin, importance and layers before specificity and order; within otherwise equal competing ordinary author rules, higher specificity wins, and a later declaration breaks an equal-specificity tie. Avoid treating “last rule wins” as a complete cascade algorithm. Inherited properties such as ordinary text color can pass from an ancestor; an explicit declaration on the child can replace the inherited value. Not every property inherits.
Each laid-out box has content, padding, border and margin. Under ordinary content-box sizing, a 300-pixel declared width plus 16-pixel padding on each side and two 2-pixel borders occupies 336 pixels before margins. Under border-box sizing, that same declared width includes padding and borders, leaving 264 pixels for content. This arithmetic is a box-model illustration; actual layout still follows the containing block, display mode and other constraints. A fixed width that fits one viewport can overflow another.
* { box-sizing: border-box; }
body { margin: 0; font: 1rem/1.6 system-ui; }
main { max-width: 60rem; margin-inline: auto; padding: 1rem; }
form { display: grid; gap: .75rem; }
input, textarea, select, button { font: inherit; max-width: 100%; }
textarea { min-height: 8rem; }
button:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, a:focus-visible { outline: 3px solid #175b87; }
@media (min-width: 48rem) {
form { grid-template-columns: 1fr 2fr; }
button { grid-column: 2; }
}Normal flow places ordinary block content sequentially. Flexbox is useful for arranging a set along a principal axis, with wrapping when appropriate. Grid coordinates rows and columns; the example uses one column by default and two at a declared available-width breakpoint. Absolute positioning removes an element from normal flow and needs a deliberate containing-block plan; using fixed coordinates for every form control makes text enlargement fragile. Responsive design responds to content and available space rather than assigning one layout to every device sold under a particular name. The viewport metadata allows a mobile browser to use an appropriate layout viewport; it does not make an overflowing layout responsive by itself.
At a narrow width, the labels and controls follow document order in a single column. At the example's wider breakpoint, alternating labels and controls occupy two columns. If help text is inserted, the grid placement must be reconsidered: a new child can shift later cells. Styling must not make the visual order contradict the keyboard/read order. Use relative constraints, test long words and permit content growth. A screenshot at one width cannot establish usable reflow at another width or at enlarged text.
Accessible operation is observable behavior
Test the form using the keyboard alone. Focus should reach the link and controls in a sensible order, remain visibly identifiable, and activate native controls with their expected keys. A placeholder is not a durable replacement for a label. Explain a failed field in text, associate its help/error with the control and set `aria-invalid="true"` when appropriate; remove that state after correction. An error summary can link to affected controls. When dynamically adding an error summary, choose a focus/status-announcement strategy deliberately rather than moving focus after every keystroke. Retain safe submitted values so recovery does not require re-entering unrelated work.
Color, contrast, screen-reader naming, zoom/reflow and keyboard behavior require their own observations. A successful automated label check does not establish that an error message is understandable or that a real screen-reader user completed the task. Likewise a mouse click on a custom div does not establish keyboard activation. Prefer native semantics and add ARIA only to describe behavior the implementation actually supplies. These are educational evaluation criteria, not a claim that this draft has already passed a complete accessibility audit.
Optional changed record and complete reasoning
A colleague removes `name="hours"`, replaces its label with a placeholder, sets the panel's content width to 300 pixels with 16-pixel padding and 2-pixel borders, and displays green “saved” text as soon as Submit is clicked. The viewport has only 320 pixels of available width. Explain each independent failure, repair it and describe the evidence you would collect. Then change the response to a 409 after the connection briefly appears stalled.
Compare the complete changed-record reasoning
**Model reasoning.** Without a name, the hours control contributes no ordinary named entry for that field in the form submission; restore the name and inspect the actual request. A disappearing placeholder fails to provide the persistent explicit label used in the original design; restore the connected label and check its accessible name. The content-box arithmetic gives 336 pixels before margins, exceeding the available 320; use a fitting fluid constraint and border-box policy, then verify the resulting layout at narrow width and enlarged text. Green text communicates no persistence proof and cannot be the only indication of state; display pending until the actual response, then an explicit saved or failed/conflict state. A 409 calls for authorized state review and a deliberate resolution path, not an unconditional automatic overwrite. If a response was lost rather than received, use a stable operation ID to reconcile the ambiguous outcome; do not manufacture another order to make the banner appear successful.
Evaluate the optional response on four equal criteria: correct document/submission semantics; box/layout mechanism and changed-width reasoning; accessible error/focus recovery; and request/persistence/identity reasoning. Preserve the original unit's authorization and retry models; this addition supplies their missing document/layout preparation.
Optional provenance: MDN Forms and buttons in HTML and Responsive web design. Fresh consultation for this draft was limited to their displayed introductions, prerequisites and learning outcomes; full sections and linked demonstrations were not reviewed. All teaching, markup and fictional records above are original Academy material.