Key Concepts

Review core concepts you need to learn to master this subject

<table> Table Element

<table> <!-- rows and columns will go here --> </table>

In HTML, the <table> element has content that is used to represent a two-dimensional table made of rows and columns.

<tr> Table Row Element

<table> <!-- rows and columns will go here --> </table>

In HTML, the table row element, <tr>, is used to add rows to a table before adding table data and table headings.

<td> Table Data Element

<table> <!-- rows and columns will go here --> </table>

The table data element, <td>, can be nested inside a table row element, <tr>, to add a cell of data to a table.

colspan Attribute

<table> <!-- rows and columns will go here --> </table>

The colspan attribute on a table header <th> or table data <td> element indicates how many columns that particular cell should span within the table. The colspan value is set to 1 by default and will take any positive integer between 1 and 1000.

rowspan Attribute

<table> <!-- rows and columns will go here --> </table>

Similar to colspan, the rowspan attribute on a table header or table data element indicates how many rows that particular cell should span within the table. The rowspan value is set to 1 by default and will take any positive integer up 65534.

<tbody> Table Body Element

<table> <!-- rows and columns will go here --> </table>

The table body element, <tbody>, is a semantic element that will contain all table data other than table heading and table footer content. If used, <tbody> will contain all table row <tr> elements, and indicates that <tr> elements make up the body of the table. <table> cannot have both <tbody> and <tr> as direct children.

<thead> Table Head Element

<table> <!-- rows and columns will go here --> </table>

The table head element, <thead>, defines the headings of table columns encapsulated in table rows.

<tfoot> Table Footer Element

<table> <!-- rows and columns will go here --> </table>

The table footer element, <tfoot>, uses table rows to give footer content or to summarize content at the end of a table.

<th> Table Heading Element

<table> <!-- rows and columns will go here --> </table>

In HTML, the table heading element, <th>, is used to add titles to rows and columns of a table and must be enclosed in a table row element, <tr>.

Tables
Lesson 1 of 1
  1. 1
    There are many websites on the Internet that display information like stock prices, sports scores, invoice data, and more. This data is naturally tabular in nature, meaning that a table is often th…
  2. 2
    Before displaying data, you must first create the table that will contain the data by using the element. The element will contain all of the tabular data you plan on displaying.
  3. 3
    In many programs that use tables, the table is already predefined for you, meaning that it contains the rows, columns, and cells that will hold data . In HTML, all of these components must be crea…
  4. 4
    Rows aren’t sufficient to add data to a table. Each cell element must also be defined. In HTML, you can add data using the table data element: . 73 81 In the example a…
  5. 5
    Table data doesn’t make much sense without titles to describe what the data represents. To add titles to rows and columns, you can use the table heading element: . The table heading element is…
  6. 6
    So far, the tables you’ve created have been a little difficult to read because they have no borders. In older versions of HTML, a border could be added to a table using the border attribute and s…
  7. 7
    What if the table contains data that spans multiple columns? For example, a personal calendar could have events that span across multiple hours, or even multiple days. Data can span columns using…
  8. 8
    Data can also span multiple rows using the rowspan attribute. The rowspan attribute is used for data that spans multiple rows (perhaps an event goes on for multiple hours on a certain day). It acc…
  9. 9
    Over time, a table can grow to contain a lot of data and become very long. When this happens, the table can be sectioned off so that it is easier to manage. Long tables can be sectioned off using …
  10. 10
    In the last exercise, the table’s headings were kept inside of the table’s body. When a table’s body is sectioned off, however, it also makes sense to section off the table’s headings using the e…
  11. 11
    The bottom part of a long table can also be sectioned off using the element. Quarter Revenue Costs Q1 $10M $7.5M …
  12. 12
    Tables, by default, are very bland. They have no borders, the font color is black, and the typeface is the same type used for other HTML elements. You can use CSS to style tables. Specifically, yo…
  13. 13
    Great job! In this lesson, you learned how to create a table, add data to it, and section the table into smaller parts that make it easier to read. Let’s review what you’ve learned so far: 1. The…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo