Sub topic 2
Grouping, Ordering, and Layout
This chapter assumes you know basic HTML form elements, JavaScript or TypeScript, and how a browser submits form data. The focus here is the information structure around fields: which questions belong together, the order users encounter them, and how the layout adapts across screen sizes.
Group related questions
A form should reflect the user's task, not the database schema. Group fields when they share a decision, object, or moment in the process.
For example, a checkout form might use these groups:
- Contact: email address and phone number.
- Delivery: delivery method and address.
- Payment: card details and billing address.
- Review: a read-only summary before submission.
In HTML, use fieldset and legend when several controls form one conceptual group. The legend gives the group a name that assistive technology can announce.
<fieldset>
<legend>Delivery method</legend>
<label>
<input type="radio" name="delivery" value="ship">
Ship to an address
</label>
<label>
<input type="radio" name="delivery" value="pickup">
Pick up in a store
</label>
</fieldset>A group should answer one question or support one decision. Avoid putting unrelated fields inside a large “Additional information” section. Broad groups make scanning harder and hide the relationship between fields.
Order fields by user knowledge
Order questions from known and easy to answer toward less certain or more demanding questions. A common sequence is:
- Identify the user or account.
- Ask for the main choice.
- Ask for details that depend on that choice.
- Confirm optional preferences.
- Show a review or confirmation.
This order reduces unnecessary work. If a user chooses pickup, do not ask for a shipping address first.
Within a group, use the natural reading order. For an address, country may determine the available region options, and the postal code may affect address suggestions. If one answer changes another field, place the controlling question first.
Do not force users to provide information the service does not need. Optional fields should be visibly marked, or required fields should be stated clearly. A long form feels shorter when every question has a clear purpose.
Choose a layout that supports scanning
A single-column layout is usually the safest default. It gives fields a predictable reading order and works well on narrow screens. Use multiple columns only when the relationship between fields is obvious and the fields are short, such as:
- First name and last name.
- City, region, and postal code.
- Month and year for an expiration date.
Keep each column aligned and avoid placing fields with very different heights side by side. A tall textarea next to a short input creates an unclear scan path.
| Layout choice | Good use | Main risk |
|---|---|---|
| Single column | Most forms and mobile layouts | Long vertical scrolling |
| Two columns | Closely related short fields | Users may read the order incorrectly |
| Sections with spacing | Distinct tasks in one form | Too many sections increase cognitive load |
Use spacing, headings, and alignment to show hierarchy. Do not rely on color alone to distinguish groups. Responsive CSS can change a two-column arrangement to one column without changing the logical order.
Separate visual order from data dependencies
CSS visual reordering can make a form appear to follow a different sequence from its keyboard or screen-reader order. That mismatch causes confusion. Keep the DOM order aligned with the intended task order, then use layout rules that preserve it.
Review the grouping with real tasks
Before implementing a layout, write the user's task in one sentence. Then check every group and field against that task.
Test the form at narrow and wide widths. Tab through it without a mouse. Confirm that the visual order, keyboard order, and submission order agree. Ask a test user to find a specific field without giving them directions. Their search behavior often exposes weak group labels or misplaced questions.
Exercise
A registration form asks for email, password, marketing preferences, full name, and country. How could you group and order these fields?
Show answer
Put email and password in an account group, full name in a profile group, country where it affects later options, and marketing preferences last as an optional choice. Keep the groups in a single-column reading order.