<> HTML Foundations

Understand semantic HTML, document structure, forms, accessibility and SEO-ready markup.

Lessons

Sign in to save progress
1 HTML Tutorial 2 HTML HOME 3 HTML Introduction 4 HTML Editors 5 HTML Basic 6 HTML Elements 7 HTML Attributes 8 HTML Headings 9 HTML Paragraphs 10 HTML Styles 11 HTML Formatting 12 HTML Quotations 13 HTML Comments 14 HTML Colors 15 HTML CSS 16 HTML Links 17 HTML Images 18 HTML Favicon 19 HTML Page Title 20 HTML Tables 21 HTML Lists 22 HTML Block & Inline 23 HTML Div 24 HTML Classes 25 HTML Id 26 HTML Buttons 27 HTML Iframes 28 HTML JavaScript 29 HTML File Paths 30 HTML Head 31 HTML Layout 32 HTML Responsive 33 HTML Computercode 34 HTML Semantics 35 HTML Style Guide 36 HTML Entities 37 HTML Symbols 38 HTML Emojis 39 HTML Charsets 40 HTML URL Encode 41 HTML vs. XHTML 42 HTML Forms 43 HTML Form Attributes 44 HTML Form Elements 45 HTML Input Types 46 HTML Input Attributes 47 Input Form Attributes 48 HTML Graphics 49 HTML Canvas 50 HTML SVG 51 HTML Media 52 HTML Video 53 HTML Audio 54 HTML Plug-ins 55 HTML YouTube 56 HTML Web APIs 57 HTML Geolocation 58 HTML Drag and Drop 59 HTML Web Storage 60 HTML Web Workers 61 HTML SSE 62 HTML Certificate 63 HTML Examples 64 HTML Editor 65 HTML Quiz 66 HTML Exercises 67 HTML Challenges 68 HTML Website 69 HTML Syllabus 70 HTML Study Plan 71 HTML Interview Prep 72 HTML Bootcamp 73 HTML Summary 74 HTML Accessibility 75 HTML References 76 HTML Tag List 77 HTML Attributes Reference 78 HTML Global Attributes 79 HTML Browser Support 80 HTML Events 81 HTML Colors Reference 82 HTML Canvas Reference 83 HTML Audio/Video 84 HTML Doctypes 85 HTML Character Sets 86 HTML URL Encode Reference 87 HTML Lang Codes 88 HTTP Messages 89 HTTP Methods 90 PX to EM Converter 91 Keyboard Shortcuts

HTML Tables

HTML Foundations Lesson 20 of 91 ~7 min read

Overview

HTML Tables is part of the complete HTML syllabus. This lesson explains the concept deeply, shows the exact tags or attributes to use, and gives you a runnable browser example for practice.

HTML Tables is about choosing markup that carries meaning before styling begins. Good HTML gives the page a reliable structure, makes the content easier to maintain, and gives browsers, search engines, forms, and assistive technologies the information they need.

Core Ideas

  • Use HTML Tables to improve the meaning of the document, not only the appearance.
  • Keep labels, headings, landmarks, and relationships explicit.
  • Prefer built-in browser behavior whenever it already solves the job.
  • Check that the page still makes sense when CSS and JavaScript are unavailable.

Step by Step

  1. Identify the content relationship that HTML Tables needs to express.
  2. Choose the native element, attribute, or browser API that matches that relationship.
  3. Add the smallest useful markup first, then add progressive enhancements.
  4. Validate the result with keyboard navigation, browser tools, and source inspection.

Beginner Explanation

HTML Tables teaches how to represent row-and-column data. Use tables for data like prices, schedules, scores, reports, and comparison grids.

A table should have a caption when the purpose is not obvious, header cells that describe rows or columns, and a logical reading order.

Do not use tables to create page layouts. CSS Grid and Flexbox are better for layout; tables are for tabular relationships.

Before You Start

  • Confirm that the content for HTML Tables is true row-and-column data.
  • List the column names before writing the table markup.
  • Decide whether the table needs a caption, row headers, or column headers.

Key Tags and Attributes

  • table: wraps tabular data.
  • caption: names the table for users and assistive technology.
  • th with scope: identifies row or column headers.
  • thead, tbody, tfoot: group table rows into meaningful sections.

Plain-English Glossary

  • Row: a horizontal group of cells in a table.
  • Column: a vertical group of related cells.
  • Header cell: a th cell that explains a row or column.
  • Caption: a short title that explains what the table is about.

What You Will Learn

  • Use HTML Tables only for information that belongs in rows and columns.
  • Build tables with captions, header cells, body rows, and scope attributes.
  • Read a table like a user would: title first, headers second, then each data cell relationship.
  • Avoid using table markup for visual page layout.

Where You Use This in Real Projects

You use HTML Tables for reports, pricing comparisons, schedules, invoices, analytics, inventory lists, scoreboards, and admin data screens.

Good table markup makes the data understandable even before CSS turns it into a polished layout.

When to Use This

  • Use HTML Tables when cells are meaningful because of their row and column headers.
  • Use CSS Grid or Flexbox instead when you are arranging page sections or cards.
  • Use a list instead when the content is only a group of related items without columns.

Browser and Accessibility Notes

  • Screen readers can announce table headers when th and scope are used correctly.
  • A caption helps users understand the purpose of the data before reading cells.
  • Responsive tables may need horizontal scrolling or a simplified layout on small screens.
  • Do not remove table semantics just to make styling easier.

Code Example

<table>
  <caption>HTML study plan</caption>
  <thead>
    <tr>
      <th scope="col">Topic</th>
      <th scope="col">Status</th>
    </tr>
  </thead>
  <tbody>
    <tr><th scope="row">Elements</th><td>Complete</td></tr>
    <tr><th scope="row">Forms</th><td>Practice</td></tr>
  </tbody>
</table>

Another Example

<table>
  <caption>Weekly learning schedule</caption>
  <tr>
    <th scope="col">Day</th>
    <th scope="col">Topic</th>
    <th scope="col">Time</th>
  </tr>
  <tr>
    <th scope="row">Monday</th>
    <td>HTML Elements</td>
    <td>30 min</td>
  </tr>
</table>

Example Explained

  • The caption explains what the table data represents.
  • Header cells use th so users can understand what each row or column means.
  • scope helps assistive technology connect data cells to the right headers.
  • Rows should contain related cells in a consistent order.

How to Read This Example

  1. Start with the caption or nearby heading so you know what data the HTML Tables table represents.
  2. Read the header cells before reading data cells. Headers explain what each row or column means.
  3. Check whether th uses scope. scope tells assistive technology whether the header describes a row or a column.
  4. Then add or remove one row and confirm the table still keeps the same structure.

Code Editor Example

Open a ready-made starter for this lesson in the live HTML, CSS, and JavaScript editor. You can change the code, then click Run to see the result immediately.

Open in Code Editor

Checklist

  • Use the most specific native element before reaching for a div.
  • Check the page with keyboard navigation and browser validation.
  • Keep the markup readable before adding CSS or JavaScript.

Common Mistakes

  • Using divs for everything and losing built-in semantics.
  • Adding JavaScript for behavior the browser already provides.
  • Forgetting labels, alt text, lang, viewport, or metadata that other tools rely on.

Do and Don't

  • Do: use HTML Tables for real tabular relationships.
  • Do: add captions and header cells when they help users understand the data.
  • Don't: use tables to position a page layout.
  • Don't: make header cells with bold td elements when th is the correct element.

Practice Challenge

Recreate the HTML Tables example in the code editor, then inspect the DOM and check that labels, links, and metadata still make sense without CSS.

Try These Changes

  • Change the text in the HTML Tables example and run it again.
  • Add one new related element, such as another paragraph, list item, table row, input, or link.
  • Add a class name and write a small CSS rule for it in the CSS tab.
  • Break one tag on purpose, run it, then fix it so you understand how browsers recover from mistakes.

Quick Check

  • Question: What is the main job of HTML Tables? Answer: To add meaning and structure to the page.
  • Question: Should HTML be readable without CSS? Answer: Yes, the structure should still make sense.
  • Question: What should you do after reading the example? Answer: Open it in the editor and change one thing.

Revision Questions

  • Why is HTML Tables better for this data than a group of div elements?
  • What does the caption tell the user before reading the rows?
  • Which cells are headers and which cells are data?
  • How would the table change if you added one more row or column?

Debugging Checks

  • Confirm the table has a caption or a nearby heading that explains the data.
  • Check that th cells are used for headers, not only bold styling.
  • Verify row and column counts stay consistent as new data is added.
  • Resize the screen and check that the table can still be read.

Mini Project

Create a simple comparison table for three products, plans, or lessons. Add a caption, column headers, one row header, and enough data that you can explain how each cell relates to its headers.

Mastery Check

  • You can explain why the chosen HTML for HTML Tables is more meaningful than a generic div.
  • You can identify the keyboard and accessibility behavior provided by the browser.
  • You can extend the example without breaking validation.
Create a free account to save which lessons you've finished. Save my progress