0% found this document useful (0 votes)
22 views6 pages

Learn HTML - Tables Cheatsheet - Codecademy

The document is a cheatsheet for HTML tables, detailing various elements such as <tr> for table rows, <td> for table data, <thead> for table headings, <tbody> for the table body, <th> for table headings, <tfoot> for table footers, and attributes like rowspan and colspan. Each element is explained with examples demonstrating their usage in creating structured tables. The cheatsheet serves as a quick reference for understanding and implementing HTML table elements.

Uploaded by

Controit Manaco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views6 pages

Learn HTML - Tables Cheatsheet - Codecademy

The document is a cheatsheet for HTML tables, detailing various elements such as <tr> for table rows, <td> for table data, <thead> for table headings, <tbody> for the table body, <th> for table headings, <tfoot> for table footers, and attributes like rowspan and colspan. Each element is explained with examples demonstrating their usage in creating structured tables. The cheatsheet serves as a quick reference for understanding and implementing HTML table elements.

Uploaded by

Controit Manaco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

11/26/24, 10:02 PM Learn HTML: Tables Cheatsheet | Codecademy

Cheatsheets / Learn HTML

Tables

<tr> Table Row Element

The table row element, <tr> , is used to add rows to a <table>


table before adding table data and table headings.
<tr>
...
</tr>
</table>

<td> Table Data Element

The table data element, <td> , can be nested inside a <table>


table row element, <tr> , to add a cell of data to a table.
<tr>
<td>cell one data</td>
<td>cell two data</td>
</tr>
</table>

https://www.codecademy.com/learn/learn-html/modules/learn-html-tables/cheatsheet 1/6
11/26/24, 10:02 PM Learn HTML: Tables Cheatsheet | Codecademy

<thead> Table Head Element

The table head element, <thead> , defines the headings <table>


of table columns encapsulated in table rows.
<thead>
<tr>
<th>heading 1</th>
<th>heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>col 1</td>
<td>col 2</td>
</tr>
</tbody>
</table>

https://www.codecademy.com/learn/learn-html/modules/learn-html-tables/cheatsheet 2/6
11/26/24, 10:02 PM Learn HTML: Tables Cheatsheet | Codecademy

rowspan Attribute

Similar to colspan , the rowspan attribute on a table <table>


header or table data element indicates how many rows
<tr>
that particular cell should span within the table. The
rowspan value is set to 1 by default and will take any <th>row 1:</th>
positive integer up to 65534. <td>col 1</td>
<td>col 2</td>
</tr>
<tr>
<th rowspan="2">row 2 (this row will
span 2 rows):</th>
<td>col 1</td>
<td>col 2</td>
</tr>
<tr>
<td>col 1</td>
<td>col 2</td>
</tr>
<tr>
<th>row 3:</th>
<td>col 1</td>
<td>col 2</td>
</tr>
</table>

https://www.codecademy.com/learn/learn-html/modules/learn-html-tables/cheatsheet 3/6
11/26/24, 10:02 PM Learn HTML: Tables Cheatsheet | Codecademy

<tbody> Table Body Element

The table body element, <tbody> , is a semantic <table>


element that will contain all table data other than table
<tbody>
heading and table footer content. If used, <tbody> will
contain all table row <tr> elements, and indicates that <tr>
<tr> elements make up the body of the table. <table> <td>row 1</td>
cannot have both <tbody> and <tr> as direct </tr>
children.
<tr>
<td>row 2</td>
</tr>
<tr>
<td>row 3</td>
</tr>
</tbody>
</table>

<th> Table Heading Element

The table heading element, <th> , is used to add titles to <table>


rows and columns of a table and must be enclosed in a
<tr>
table row element, <tr> .
<th>column one</th>
<th>column two</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>

https://www.codecademy.com/learn/learn-html/modules/learn-html-tables/cheatsheet 4/6
11/26/24, 10:02 PM Learn HTML: Tables Cheatsheet | Codecademy

colspan Attribute

The colspan attribute on a table header <th> or table <table>


data <td> element indicates how many columns that
<tr>
particular cell should span within the table. The colspan
value is set to 1 by default and will take any positive <th>row 1:</th>
integer between 1 and 1000. <td>col 1</td>
<td>col 2</td>
<td>col 3</td>
</tr>
<tr>
<th>row 2:</th>
<td colspan="2">col 1 (will span 2
columns)</td>
<td>col 2</td>
<td>col 3</td>
</tr>
</table>

https://www.codecademy.com/learn/learn-html/modules/learn-html-tables/cheatsheet 5/6
11/26/24, 10:02 PM Learn HTML: Tables Cheatsheet | Codecademy

<tfoot> Table Footer Element

The table footer element, <tfoot> , uses table rows to <table>


give footer content or to summarize content at the end of
<thead>
a table.
<tr>
<th>heading 1</th>
<th>heading 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>col 1</td>
<td>col 2</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>summary of col 1</td>
<td>summary of col 2</td>
</tr>
</tfoot>
</table>

<table> Table Element

In HTML, the <table> element has content that is used <table>


to represent a two-dimensional table made of rows and
<!-- rows and columns will go here -->
columns.
</table>

Print Share

https://www.codecademy.com/learn/learn-html/modules/learn-html-tables/cheatsheet 6/6

You might also like