Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
HTML & Accessibility (a11y)
  1. 1.HTML Fundamentals: Structure & Core Elements
  2. 2.Lists, Tables & Basic Forms
  3. 3.Semantic HTML5 & Document Outline
  4. 4.Advanced Forms & Input Validation
  5. 5.Multimedia & Embedded Content Accessibility
  6. 6.Introduction to ARIA: Roles & Landmarks
  7. 7.ARIA States & Properties for Dynamic Content
  8. 8.Keyboard Accessibility & Focus Management
  9. 9.Advanced Accessibility Patterns & Custom Controls
  10. 10.Accessibility Testing, WCAG & Interview Prep
HTML & Accessibility (a11y)
02

Web Fundamentals · Lesson 2 of 10 · 3 min

Lists, Tables & Basic Forms

This is about precision. Interviewers use these topics to see if you know the fundamentals cold and care about accessibility.

Choose the right list for the job

Use <ul> for items where order is irrelevant. Use <ol> when it's a sequence. dl is for key-value pairs, like a glossary or metadata. That's it. Don't overthink it.

The interview question here is about semantics. Explaining why you chose ol for a recipe's steps (because the sequence is critical) versus ul for its ingredients (because the order you list them in doesn't matter) shows you understand that HTML describes content, not just style.

The trap: Nesting lists incorrectly. A sub-list must be a child of an <li>, not a sibling.

Wrong:

<li>Item 1</li>
<li>Sub-item A</li>

Right:

<li>Item 1
 <ul>
   <li>Sub-item A</li>
 </ul>
</li>

Build tables for data, not layout

This is a classic filter. If you suggest using a <table> for page layout, the interview is over. Tables are for tabular data. Period.

For a table to be accessible, a screen reader needs to understand the relationship between headers and cells. Use <caption> to give the table a title. Use <thead> and <tbody> to structure the content. Most importantly, use <th> for header cells and specify their scope.

  • scope="col" tells an assistive device that this cell is the header for everything below it in the column.
  • scope="row" tells it the cell is the header for everything to its right in the row.

Without scope, a screen reader might just read a list of disconnected cells. With scope, it can announce "Category: Rent, Amount: $1200, Due Date: 1st," which provides crucial context.

Make forms accessible from the start

A form is a contract between the user and the application. The most fundamental part of that contract is making it clear what you're asking for.

Every single input that expects user data needs a <label>. The for attribute on the <label> must match the id of the <input>, <select>, or <textarea>. This creates a programmatic link that is non-negotiable for accessibility. It allows screen readers to announce the purpose of the field, and it makes the label a larger click target for all users.

The trap: Forgetting the name attribute. An input without a name will not be included in the form's data submission. The id is for the label; the name is for the server.

The <form> element itself has two key attributes: action (the URL to send the data to) and method (the HTTP method to use). Use POST for submitting data that changes state on the server (like creating a user). Use GET for actions that retrieve data, like a search query, where the parameters can safely live in the URL.

Use the correct input type. type="email" gives you basic client-side validation and a specialized keyboard on mobile. type="password" masks the input. Using semantic types gives you browser-native features for free.

Here is the basic flow of a form submission. The browser handles the validation and data packaging before it ever hits the network.

This example shows a robust registration form structure. Note the use of <fieldset> to group related controls like checkboxes or radio buttons, with a <legend> to describe the group. This is another key accessibility pattern.

<form action="/register" method="POST">
    <div>
        <label for="username">Username:</label>
        <input type="text" id="username" name="username" required minlength="4">
    </div>
    <div>
        <label for="password">Password:</label>
        <input type="password" id="password" name="password" required minlength="8">
    </div>

    <fieldset>
        <legend>Your Interests:</legend>
        <div>
            <input type="checkbox" id="coding" name="interests" value="coding">
            <label for="coding">Coding</label>
        </div>
        <div>
            <input type="checkbox" id="design" name="interests" value="design">
            <label for="design">Design</label>
        </div>
    </fieldset>

    <fieldset>
        <legend>Preferred Communication:</legend>
        <div>
            <input type="radio" id="emailComm" name="communication" value="email" checked>
            <label for="emailComm">Email</label>
        </div>
        <div>
            <input type="radio" id="phoneComm" name="communication" value="phone">
            <label for="phoneComm">Phone</label>
        </div>
    </fieldset>

    <div>
        <label for="country">Country:</label>
        <select id="country" name="country">
            <option value="">-- Please choose an option --</option>
            <option value="usa">United States</option>
            <option value="canada">Canada</option>
        </select>
    </div>

    <button type="submit">Register</button>
</form>

Try it

Build a registration form for a fictional event. It needs fields for name and email, radio buttons to select an attendee type (e.g., "General", "VIP"), a dropdown for T-shirt size, and a required checkbox for agreeing to the terms. Ensure every input has a correctly associated label and a name attribute.

Next: We'll cover how semantic HTML5 elements define the structure of a page in the lesson on Semantic HTML5 & Document Outline.

Lock it in — apply this lesson under interview conditions.

Try an AI mock interview
Previous

HTML Fundamentals: Structure & Core Elements

Next

Semantic HTML5 & Document Outline