Accessible registration project
Definition and purpose
Combine form semantics, responsive sizing and focus styling into a registration layout. The example is a local styling exercise, not a real registration service; its inline submit handler cancels navigation. HTML constraints give immediate feedback; a real service also requires server-side validation and secure handling.
A narrow form
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { display: grid; gap: 8px; max-inline-size: 320px; } input { min-inline-size: 0; padding: 8px; } </style> </head> <body> <form id="a" onsubmit="return false"> <label for="email">Email (required)</label> <input id="email" type="email" required> <label for="pass">Password (8+ characters)</label> <input id="pass" type="password" required minlength="8"> <button id="b">Register</button> </form> </body></html>The fields stack in reading order and the form stops growing at 320px.
Syntax and mental model
A grid with one column gives labels and fields a predictable reading order. Use max-inline-size to constrain the form and min-inline-size: 0 to allow fields to shrink. A :focus-visible outline gives keyboard users a clear location cue. Keep visible labels, instructions and a native submit button.
Keyboard cue
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } input:focus-visible, button:focus-visible { outline: 3px solid navy; outline-offset: 2px; } </style> </head> <body> <form id="a" onsubmit="return false"> <label for="email">Email (required)</label> <input id="email" type="email" required> <label for="pass">Password (8+ characters)</label> <input id="pass" type="password" required minlength="8"> <button id="b">Register</button> </form> </body></html>Tab to the first input; the outline is visible.
Common mistakes
Do not rely on CSS to prevent invalid submissions or reorder fields visually away from DOM order. Do not enter real passwords into a local demo.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Scrollbars, interaction and resize. Next lesson: 2D transforms and origin.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Accessible registration project — knowledge check
Five questions on accessible registration project.
Why keep visible form labels?
Which property limits flow-relative width?
Which state helps show keyboard focus?
Does CSS validate a real registration on the server?
Which order should fields follow?