Lists
Use unordered, ordered, nested and description lists according to the meaning of the content.
CodeBhavyaOrganize related content, explain tabular data and build forms whose submitted values you can predict.
Level 08 introduced text, links and media. This lesson organizes information and collects user input. You will choose the right list, build a readable data table, associate labels with controls, and explain which values a form submits.
Use unordered, ordered, nested and description lists according to the meaning of the content.
Use captions, row and column headers, table sections and carefully chosen cell spans.
Use labels, names, groups, input types, selects and text areas with appropriate validation.
Distinguish GET from POST and predict submitted name/value pairs without confusing browser validation with server security.
Imagine a CodeBhavya workshop page. Its prerequisites are a list, its timetable is a table, and its registration area is a form. Choosing by appearance alone can create confusing markup.
Related items: prerequisites, steps or terms. Sequence matters for steps, but not for a collection of topics.
Related values across two dimensions: each workshop row has a topic, day and seat count.
Controls through which the learner provides information or requests an action.
Use CSS for arranging page regions. A table is for tabular data, not a shortcut for positioning a page.
Prerequisites β HTML basics, links, a code editor.
Workshop Γ seats β HTML Foundations has 20 seats.
Labelled controls β values ready for inspection.
Use <ul> when rearranging the items does not change their meaning. Each item belongs inside an <li>. Browser bullets are a default presentation; CSS can change their appearance.
<ul>
<li>HTML document structure</li>
<li>Links and images</li>
<li>A code editor</li>
</ul>Expected result: three related prerequisite items. A bullet is not manually typed into each item.
Use <ol> for steps, rankings or another sequence where position matters. start changes the initial number; reversed reverses numbering; an itemβs value sets its number and affects subsequent numbering.
<ol start="3">
<li>Validate the HTML.</li>
<li>Test keyboard navigation.</li>
<li>Publish the page.</li>
</ol>Expected labels: 3, 4, 5. Numbering alone does not make unrelated content a meaningful sequence.
A nested list belongs inside the parent item, before that itemβs closing tag. A description list associates terms or names with descriptions; it does not use li.
<ul>
<li>Frontend
<ul><li>HTML</li><li>CSS</li></ul>
</li>
<li>Backend</li>
</ul>
<dl>
<dt>GET</dt><dd>A method used to retrieve a representation.</dd>
<dt>POST</dt><dd>A method commonly used to submit data for processing.</dd>
</dl>A term can have multiple descriptions, and multiple terms can share a description. Use the grouping that matches your information rather than forcing every definition into a two-column table.
Contains an inner ul before the parent closing tag.
First item inside the inner list.
Second item inside the same inner list.
table contains a data table, tr creates a row, th identifies a header cell and td contains a data cell. A caption gives the table a meaningful title. thead, tbody and tfoot group rows; they do not create columns.
<table>
<caption>CodeBhavya workshop seats</caption>
<thead>
<tr><th scope="col">Workshop</th><th scope="col">Seats</th></tr>
</thead>
<tbody>
<tr><th scope="row">HTML Foundations</th><td>20</td></tr>
<tr><th scope="row">Forms Practice</th><td>15</td></tr>
</tbody>
<tfoot>
<tr><th scope="row">Total</th><td>35</td></tr>
</tfoot>
</table>| Workshop | Seats |
|---|---|
| HTML Foundations | 20 |
| Forms Practice | 15 |
| Total | 35 |
Read the result: the total is 35 seats. The HTML structure communicates the data; borders and spacing in this rendered example come from CSS.
For a simple table, scope="col" marks a column header and scope="row" marks a row header. This helps tools associate a value with its context. A visually bold td is still a data cell.
For complex tables with multiple header levels, explicit header IDs and a cellβs headers attribute may be needed. Prefer splitting a complicated table into simpler tables when that makes the information easier to understand.
Keep tables readable on phones with a horizontal scrolling wrapper. Do not remove their semantic structure merely to fit the viewport.
colspan extends a cell across columns; rowspan extends it across rows. Cells covered by a span must not also be added as ordinary cells.
<table>
<caption>Workshop session plan</caption>
<thead><tr><th scope="col">Day</th><th scope="col">Session</th></tr></thead>
<tbody>
<tr><th scope="row" rowspan="2">Monday</th><td>Lists</td></tr>
<tr><td>Tables</td></tr>
<tr><td colspan="2">Independent practice</td></tr>
</tbody>
</table>Trace the grid: Monday occupies the first column in two rows. The second row therefore contains only the Tables cell. The final practice cell occupies both columns. Complex spanning also requires careful header associations.
A form groups controls for submission. action identifies the destination, and method specifies how the browser submits the data. HTML creates the interface; a real destination needs server logic to process and validate it.
<!-- /workshop-register is an illustrative server endpoint. -->
<form action="/workshop-register" method="post">
<label for="student-name">Student name</label>
<input id="student-name" name="student" type="text" required>
<button type="submit">Register</button>
</form>The endpoint above is an example, not a working CodeBhavya registration service. The interactive lab later in this lesson prevents network submission and shows the payload locally.
id identifies an element in the document; a labelβs for matches that ID. name is the submitted field key. value supplies the field value, or its initial value for controls such as a text input.
<label for="learner-email">Email address</label>
<input id="learner-email" name="email" type="email"
placeholder="learner@example.com" required>Entering learner@example.com yields the pair email=learner@example.com. An ID does not replace a name. Placeholder text is a hint, not a persistent label. IDs should be unique in the document.
The label points to a control with id="student".
The input is identified in the page. name="student" supplies the submission key.
An eligible named control contributes its current value.
Choose a type that matches the data. Types improve browser interaction and, for some controls, provide constraints. Browser presentation varies by device.
Text is general input. Email checks an email-shaped value, not whether the address exists or belongs to the learner.
Number supports constraints such as min, max and step. Date represents a calendar date; its visible picker is browser dependent.
Password obscures the display but does not encrypt transmission. Telephone input can improve keyboard choice but has no universal built-in phone-number format check.
Required checks that an applicable control has a value. Pattern constrains applicable text-like controls; explain the expected format visibly.
<label for="seat-count">Seats requested (1β4)</label>
<input id="seat-count" name="seats" type="number"
min="1" max="4" step="1" value="1" required>Try 0, 1, 4, 5 and 1.5. The allowed values are whole numbers from 1 through 4. Client-side validation can be bypassed; the server must validate independently.
Radio buttons with the same name in the same form form a mutually exclusive group. Checkboxes represent independent choices. A checked checkbox submits its value; an unchecked one contributes no pair.
<fieldset>
<legend>Attendance mode</legend>
<label><input type="radio" name="mode" value="online" checked> Online</label>
<label><input type="radio" name="mode" value="campus"> Campus</label>
</fieldset>
<label><input type="checkbox" name="updates" value="yes"> Send workshop updates</label>Selecting Campus and leaving updates unchecked yields mode=campus, with no updates pair. Give choice controls explicit values so their meaning is clear.
A select presents options, and the selected optionβs value is submitted. A textarea accepts multiple lines; its initial content goes between its tags. A fieldset groups related controls and its legend names that group.
<label for="topic">Workshop topic</label>
<select id="topic" name="topic" required>
<option value="">Choose a topic</option>
<option value="html">HTML Foundations</option>
<option value="forms">Forms Practice</option>
</select>
<label for="notes">Learning goal</label>
<textarea id="notes" name="notes" rows="3">Practise accessible forms.</textarea>
<button type="submit">Submit</button>
<button type="reset">Restore defaults</button>
<button type="button">Show help</button>Inside a form, a button without an explicit type commonly acts as a submit button. Use type="button" for helper actions. Reset restores initial defaults, which may not be empty values; it does not erase data already stored by a server.
For the basic controls in this lesson, a submitted pair generally needs a name and an enabled control. Unchecked checkboxes and radios are omitted. A selected option contributes its value. Repeated names can produce multiple pairs.
A disabled control is omitted and does not participate in constraint validation. It is not a security boundary.
A read-only text control can still submit its named value. Readonly applies only to supported control types; it does not make a select read-only.
A hidden input contributes a named value, but users can inspect and modify it. Never trust a hidden price or role without server checks.
A named submit button can contribute its own name/value when it is the submitter. A helper button is not submitted as a field.
<input name="course" value="HTML" readonly>
<input name="internalNote" value="Draft" disabled>
<input value="Unnamed field">
<input type="checkbox" name="updates" value="yes">Expected pairs: only course=HTML, assuming the checkbox remains unchecked. The lab uses an unnamed submit button, so its button adds no field.
A GET form typically puts encoded data in the URL query. It suits retrieval such as searching. A POST form typically sends data in the request body and is commonly used for actions that change server state. POST by itself is not encryption; HTTPS protects transport for both methods.
The usual form encoding is application/x-www-form-urlencoded. Spaces become + and special characters are escaped. Repeated fields remain separate pairs. File uploads normally use POST with enctype="multipart/form-data".
<!-- Illustrative search endpoint; not a live CodeBhavya route. -->
<form action="/search" method="get">
<label for="query">Search lessons</label>
<input id="query" name="q" value="HTML forms">
<button type="submit">Search</button>
</form>
<!-- Expected request target: /search?q=HTML+forms -->Do not place passwords in GET queries. A POST body still needs careful handling, server validation, authorization and appropriate protection against unwanted requests.
Illustration: /workshop-register?student=Asha. Query data is part of the URL.
Illustration: student=Asha in the body with a suitable content type.
Neither method replaces HTTPS, authorization or server validation.
Follow the sequence from input to processing. This is a conceptual journey; the lab stops before a real network request.
The learner enters a fictional name and selects the workshop options. Nothing has been sent.
student = Asha; topic = html; seats = 1The form stores current control values in the page. This visualizer explains a fixed example; the next lab lets you inspect your own changes.
Inspect real browser-generated form pairs. Nothing is submitted to a server or saved by this lab. Use fictional data. Change the method to compare the same data as a URL query and a request body.
Press Inspect submission to see which fields contribute.
<form id="wt9Form" action="/workshop-register" method="post">
<label for="wt9Student">Learner name (use a fictional name)</label><input id="wt9Student" name="student" value="Asha" required maxlength="60">
<label for="wt9Email">Practice email</label><input id="wt9Email" name="email" type="email" value="asha@example.com" required>
<label for="wt9Topic">Topic</label><select id="wt9Topic" name="topic" required><option value="">Choose a topic</option><option value="html" selected>HTML Foundations</option><option value="forms">Forms Practice</option></select>
<label for="wt9Seats">Seats (1β4)</label><input id="wt9Seats" name="seats" type="number" min="1" max="4" step="1" value="1" required>
<fieldset><legend>Attendance mode</legend><label class="wt9-choice"><input type="radio" name="mode" value="online" checked>Online</label><label class="wt9-choice"><input type="radio" name="mode" value="campus">Campus</label></fieldset>
<label class="wt9-choice"><input type="checkbox" name="updates" value="yes">Include workshop updates</label>
<label for="wt9Course">Course (read-only)</label><input id="wt9Course" name="course" value="Web Technologies" readonly>
<label for="wt9Draft">Internal note (disabled)</label><input id="wt9Draft" name="internalNote" value="Draft" disabled>
<label for="wt9Notes">Learning goal</label><textarea id="wt9Notes" name="notes" rows="3">Practise forms.</textarea>
<div class="wt9-actions"><button class="primary-button" type="submit">Inspect submission</button><button class="secondary-button" type="reset">Restore defaults</button></div>
</form>The endpoint shown is illustrative. The lab prevents submission even if its script fails to initialize. Copied HTML needs an actual server endpoint and server-side validation before it becomes a real registration form.
Move the inner ul or ol inside the li it describes. Read the DOM tree rather than judging only indentation.
Use th and appropriate scope. A bold font alone does not communicate header relationships.
A control can be visible and labelled yet absent from the payload. Check name separately from id.
Different names allow simultaneous selection. Use one shared name for alternatives in the same group.
Disabled controls are omitted. If a text value should submit while not being editable, consider readonly where supported.
Use HTTPS and server checks. Moving data from the query to the body does not encrypt it.
Add a visible label. Hints disappear during typing and do not replace the controlβs name for users.
Set type="button" on helper buttons inside a form.
Reveal each answer, then explain it in your own words with an example.
Use ol when sequence or ranking is meaningful; use ul for a related collection without meaningful order.
id identifies the element and connects labels or fragments. name supplies the submitted field key.
They communicate header relationships in simple data tables. A styled td remains a data cell.
No. POST usually places data in the body. HTTPS protects transport; server validation is still needed.
It contributes no name/value pair. Server logic must handle an absent field appropriately.
A named read-only text field can submit. A disabled field is omitted and does not participate in validation.
No. Users can bypass browser checks or send requests directly. Validate all submitted data on the server.
They group related controls and provide a group label, for example attendance radio choices.
Choose an answer to see why it is correct. Use Reset quiz to practise again.
Create three prerequisites with ul. Expected: three sibling li items. Reorder them and explain why the meaning remains intact.
Use ol start="4" with three items. Expected labels: 4, 5, 6. Add value="10" to the second item and predict 4, 10, 11.
Create HTML and CSS as children of Frontend. Expected: the inner list is contained within the Frontend li.
Create two workshops with 20 and 15 seats. Expected total: 35. Add a caption and headers with scope.
Make a day header cover two sessions. Expected: the second session row has no duplicate day cell.
In the lab, uncheck updates and inspect. Expected: no updates pair. Switch attendance to campus; expected mode=campus.
Try seats 0, 1, 4, 5 and 1.5. Expected: only 1 and 4 pass among these values. Try an empty topic and a malformed email; browser validation blocks inspection.
Use name Asha & Ravi. Expected encoding: student=Asha+%26+Ravi. Change seats and reset; expected initial seats 1, not an empty field.
One li within an ordered or unordered list.
The title of a table.
A th that identifies row or column context.
A cellβs extension across multiple rows or columns.
An input, select, textarea or another interactive form element.
The key submitted with a controlβs value.
Browser checks for applicable input requirements.
A representation of data suitable for transmission.
The data carried by a request.
An editing restriction supported by certain control types.
Build a complete HTML document with a prerequisites list, an ordered preparation plan, a captioned timetable and a labelled registration form. Include a topic selector, radio group, optional updates checkbox and seat count from 1 to 4.
Success criterion: explain every submitted field and every omitted field without guessing from its appearance.
Before marking complete, build a list and a simple accessible table, label a form correctly, and predict its submitted pairs. Completion records a local study milestone; it is not an assessment score.