Lecture 7 Demo

HTML Tables & Iframes

[Classroom Tip] This demo demonstrates semantic table structure, colspan & rowspan cell merging, table accessibility with scope, and iframe sandboxing — all interactive.

1) Semantic Table Structure

A well-structured table uses <caption>, <thead>, <tbody>, and <tfoot>.

<table>
  <caption>Course Grades</caption>
  <thead>
    <tr>
      <th scope="col">Student</th>
      <th scope="col">Assignment</th>
      <th scope="col">Score</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Alice</td>
      <td>Lab 1</td>
      <td>92%</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="2">Average</td>
      <td>87%</td>
    </tr>
  </tfoot>
</table>
Result:
Course Grades — WebTech 2026
Student Assignment Score
AliceLab 192%
BobLab 185%
CarolLab 189%
AliceLab 295%
BobLab 278%
Average87.8%

2) Colspan & Rowspan — Cell Merging

Click a header row button to highlight how cells span across columns or rows.

Colspan (across columns):
Monthly Schedule (colspan="3")
Lecture Lab Tutorial
Combined Lecture+Lab Tutorial
<th colspan="3">Monthly Schedule</th>
<td colspan="2">Combined Lecture+Lab</td>
Rowspan (across rows):
Day Session Room
Mon Lecture A101
Tutorial B204
Tue Lab Lab03
<td rowspan="2">Mon</td>

3) Accessibility: scope Attribute

The scope attribute tells screen readers whether a <th> applies to a column or a row.

<th scope="col">...</th>
<!-- Header for an entire column -->

<th scope="row">...</th>
<!-- Header for an entire row -->

Without scope, screen readers cannot determine which header belongs to which cell — breaking table navigation for blind users.

Exam Scores (with scope attributes)
Midterm Final Average
Alice 829186.5
Bob 748077
Carol 909592.5

Blue headers = scope="col" | Navy headers = scope="row"

4) Live Table Builder

Set rows and columns, then click Generate to build a table skeleton.

5) <iframe> & the Sandbox Attribute

The sandbox attribute restricts what embedded content can do. Toggle features on/off below.

Sandbox permissions:
Generated attribute:
<iframe
  src="embed.html"
  sandbox=""
  width="400"
  height="200">
</iframe>
Security note:
  • No sandbox → embedded page has full access (risky for user content)
  • sandbox="" → most restrictive — scripts, forms, popups all blocked
  • Add only the permissions you actually need
  • Never use allow-same-origin + allow-scripts together — it can escape the sandbox
🔒
iframe sandbox state: fully locked