{ "$schema": "../schemas/code-crispies-module-schema.json", "id": "html-tables", "title": "HTML Tables", "description": "Create structured data tables with semantic markup", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "table-basic", "title": "Data Tables", "description": "Tables display structured data in rows and columns. Use <table> as the container, <tr> for rows, <th> for header cells, and <td> for data cells.

Add <caption> for an accessible title that describes the table's content.", "task": "Create a pricing table:
1. A <caption> saying Pricing
2. A header row with Plan and Price
3. Two data rows for Basic ($9) and Pro ($29)", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; } table { border-collapse: collapse; width: 100%; max-width: 350px; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 16px; font-weight: 600; font-size: 1.1rem; color: #333; background: #f8f9fa; } th, td { padding: 14px 20px; text-align: left; border-bottom: 1px solid #eee; } th { background: steelblue; color: white; font-weight: 500; } tr:last-child td { border-bottom: none; } tr:hover td { background: #f8f9fa; }", "sandboxCSS": "", "initialCode": "", "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n
Pricing
PlanPrice
Basic$9
Pro$29
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "table", "message": "Add a <table> element" }, { "type": "element_exists", "value": "caption", "message": "Add a <caption> for the table title" }, { "type": "element_count", "value": { "selector": "th", "min": 2 }, "message": "Add header cells (<th>) for Plan and Price" }, { "type": "element_count", "value": { "selector": "tr", "min": 3 }, "message": "Add 3 rows (1 header + 2 data rows)" } ] }, { "id": "table-sections", "title": "Table Sections", "description": "Semantic table sections improve accessibility and allow for separate styling:

<thead> — header section
<tbody> — main content
<tfoot> — footer (totals, summaries)", "task": "Wrap the header row in <thead> and data rows in <tbody>.", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } table { border-collapse: collapse; width: 100%; max-width: 350px; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } th, td { padding: 12px 16px; text-align: left; } thead { background: steelblue; color: white; } tbody tr:nth-child(even) { background: #f8f9fa; }", "sandboxCSS": "", "initialCode": "\n \n \n \n \n \n \n \n \n \n \n \n \n
NameScore
Alice95
Bob87
", "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
NameScore
Alice95
Bob87
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "thead", "message": "Add a <thead> section for the header" }, { "type": "element_exists", "value": "tbody", "message": "Add a <tbody> section for the data" } ] }, { "id": "table-colspan", "title": "Spanning Columns", "description": "The colspan attribute lets a cell span multiple columns. This is useful for headers that group multiple columns or footer totals.

<td colspan=\"2\">...</td>
", "task": "Add a footer row that spans both columns using colspan=\"2\".", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } table { border-collapse: collapse; width: 100%; max-width: 350px; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #eee; } thead { background: steelblue; color: white; } tfoot { background: #f0f0f0; font-weight: 600; }", "sandboxCSS": "", "initialCode": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
ItemPrice
Coffee$4
Cake$6
", "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
ItemPrice
Coffee$4
Cake$6
Total: $10
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "tfoot", "message": "Add a <tfoot> section" }, { "type": "contains", "value": "colspan", "message": "Use colspan to span columns" } ] } ] }