10 of 3033%
beginnerHTML33% complete

Tables

Learn Tables through checkout form: what it does, when to use it, the code pattern, and a small task you can test immediately.

This lesson gives you

3 Working code
3 Practice tasks
5 Interview answers

Plain meaning

Tables is a HTML pattern for one practical job. Learn the input, apply the smallest working syntax, check the output, then reuse the pattern in a real feature.

Why it matters

Tables matters because real HTML work needs consistent ways to collect customer details. Without this pattern, the feature becomes harder to change, test and review.

Real use

In a real project, tables helps build an accessible product checkout page using labels, fields and helper text.

Working example

Core pattern

This is the version to read first, run next, and modify last.

<table>
  <caption>Monthly orders</caption>
  <thead><tr><th>Customer</th><th>Total</th></tr></thead>
  <tbody><tr><td>Asha</td><td>$59</td></tr></tbody>
</table>

Expected output

The browser renders checkout form with structure that screen readers and search engines can understand.

Line by line

What each part does

1

Line 1 sets up the Tables example: <table>.

2

Line 2 adds one required part of the working pattern: <caption>Monthly orders</caption>.

3

Line 3 adds one required part of the working pattern: <thead><tr><th>Customer</th><th>Total</th></tr></thead>.

4

Line 4 adds one required part of the working pattern: <tbody><tr><td>Asha</td><td>$59</td></tr></tbody>.

5

Line 5 adds one required part of the working pattern: </table>.

Methods and commands

Tables reference

Use these methods, commands, tags or properties with the working example above.

<main>

<main>...</main>

Wrap the primary page content.

<main><h1>Dashboard</h1></main>

<section>

<section aria-labelledby="id">...</section>

Group a standalone page section.

<section aria-labelledby="pricing"><h2 id="pricing">Pricing</h2></section>

<article>

<article>...</article>

Mark content that can stand alone.

<article><h2>Product update</h2><p>...</p></article>

<form>

<form action="/save" method="post">...</form>

Collect and submit user input.

<form><input name="email" type="email" required /></form>

<label>

<label for="email">Email</label>

Connect visible text to an input.

<label for="email">Email</label><input id="email" />

alt

<img src="photo.jpg" alt="Team dashboard" />

Describe meaningful images for accessibility.

<img src="chart.png" alt="Sales chart" />

aria-labelledby

aria-labelledby="heading-id"

Name a region using an existing heading.

<section aria-labelledby="faq"><h2 id="faq">FAQ</h2></section>

required

<input required />

Tell the browser an input must be filled.

<input name="email" type="email" required />

Try it yourself

Edit and run the concept

Change one thing at a time so the output stays easy to understand.

HTML Tables editor
lesson.html
1
2
3
4
5
html5 linesWrap
Preview

Terminal

Success

Ready.

Run code to see output here.

Examples

Three useful variations

Compare the examples by level. Each one keeps the same idea but changes the situation.

Beginner example

html
<table>
  <caption>Monthly orders</caption>
  <thead><tr><th>Customer</th><th>Total</th></tr></thead>
  <tbody><tr><td>Asha</td><td>$59</td></tr></tbody>
</table>

The browser renders checkout form with structure that screen readers and search engines can understand.

Intermediate example

html
<table>
  <caption>Monthly orders</caption>
  <thead><tr><th>Customer</th><th>Total</th></tr></thead>
  <tbody><tr><td>Asha</td><td>$60</td></tr></tbody>
</table>

The browser renders checkout form with structure that screen readers and search engines can understand.

Advanced example

html
<table>
  <caption>Monthly orders</caption>
  <thead><tr><th>Customer</th><th>Total</th></tr></thead>
  <tbody><tr><td>Asha</td><td>$61</td></tr></tbody>
</table>

The browser renders checkout form with structure that screen readers and search engines can understand.

Practice

Build understanding

1

Rewrite the Tables example for checkout form using your own labels or data.

2

Add one edge case from labels, fields and helper text and record the output.

3

Explain where Tables fits inside an accessible product checkout page.

Mini task

Build a tiny an accessible product checkout page step that uses Tables, then write the expected output before running it.

Checklist

Use it correctly

  • Tables is easier when connected to a real task.
  • Small examples are the fastest way to catch misunderstandings.
  • Practice, quiz review and projects reinforce the lesson.
  • Line-by-line review turns copied code into understood code.

Common mistake

Skipping the small tables example and trying to memorize the rule first.

Best practice

Use descriptive names so the example explains itself.

Interview prep

Tables questions

Use these as concise model answers, then rewrite them in your own words.

1. What is Tables in HTML?

Tables is a specific HTML pattern used to make a common task easier to read, write, test, or explain. A strong answer includes the purpose, a tiny example, and the result you expect after running it.

2. Why do developers use tables?

Tables matters because real HTML work needs consistent ways to collect customer details. Without this pattern, the feature becomes harder to change, test and review.

3. How would you use tables in a real project?

In a real project, tables helps build an accessible product checkout page using labels, fields and helper text. Start with the simple syntax, keep names clear, run the code, then handle one edge case before expanding the feature.

4. What mistake should a beginner avoid with tables?

Skipping the small tables example and trying to memorize the rule first.

5. How would you explain HTML Introduction in HTML during an interview?

HTML Introduction is best explained with its purpose, a small example, and one common mistake.

6. How would you explain Document Structure in HTML during an interview?

Document Structure is best explained with its purpose, a small example, and one common mistake.

Simple rule

Start with the working example, change one value, run it again, and explain why the output changed. That makes tables useful instead of memorized.