logo Learn HTML
  • Home
  • Tutorials
  • Practice
  • Quiz
  • Projects
  • About
  • Contact

HTML Course

  • HTML HOME
  • HTML Introduction
  • HTML Basic
  • HTML Element
  • HTML Attributes
  • HTML Headings
  • HTML Paragrapha
  • HTML Style
  • HTML Formattin
  • HTML Quotations
  • HTML Colors
  • HTML Css
  • HTML Links
  • HTML Image
  • HTML Favicon
  • Page Tittle
  • HTML Tables
  • HTML Lists
  • Block & Inline
  • HTML Div
  • HTML Classes
  • HTML Id
  • HTML Buttons
  • HTML Iframes
  • HTML File Paths
  • HTML Head
  • HTML Layout
  • HTML Symbols
  • HTML Emojis
  • HTML URL Encode
  • HTML VS XHTML
  • HTML FROM
  • HTML Form
  • Form Attributes
  • Form Elements
  • HTML Input Types
  • HTML Input Attributes
  • Input Form Attributes
  • HTML Graphics
  • HTML Canvas
  • HTML SVG
  • HTML Media
  • HTML Media
  • HTML Video
  • HTML Audio
  • HTML Plug-ins
  • HTML Youtube
  • HTML APIS
  • HTML Web APIS
  • HTML Geolocation
  • HTML Drag & Drop
  • Web Storage
  • Web Workers
  • HTML SSE
  • HTML Examples
  • HTML Examples
  • HTML Editor
  • HTML Quiz
  • HTML Exercises
  • HTML References
  • HTML Tag List
  • HTML Attributes
  • HTML Global Attributes
  • HTML Brower Support
  • HTML Events
  • HTML Colors
  • HTML Canvas
  • HTML Audio & Video
  • HTML Doctypes
  • HTML Character Sets
  • HTML URL Encode
  • Language Codes
  • HTTP Messages
  • HTTP Methods
  • PX to EM Converter
  • keyboard Shortcuts

HTML Tables


HTML tables allow web developers to arrange data into rows and columns.


Example

Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Centro comercial Moctezuma Francisco Chang Mexico
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy

Define an HTML Table

A table in HTML consists of table cells inside rows and columns.

Example

A simple HTML table:

<table>

<thead>

<th> Company </th>

<th> Contact </th>

<th> Country </th>

</thead>

<tbody>

<tr>

<td> Alfreds Futterkiste </td>

<td> Maria Anders </td>

<td> Germany</td>

</tr>

<tr>

<td> Centro comercial Moctezuma </td>

<td> Francisco Chang </td>

<td> Mexico</td>

</tr>

</tbody>

</table>


Table Cells

Each table cell is defined by a <td> and a <td> tag.

td stands for table data.

Everything between <td> and </td> is the content of a table cell.

Example

<table>

<tr>

<td> Emil </td>

<td> Tobias </td>

<td> Linus</td>

</table>


Note :A table cell can contain all sorts of HTML elements: text, images, lists, links, other tables, etc.


Table Rows

ach table row starts with a <tr> and ends with a </tr> tag.

Example

<table>

<tr>

<td> Emil </td>

<td> Tobias </td>

<td> Linus</td>

</tr>

<tr>

<td> 16 </td>

<td> 14 </td>

<td> 10</td>

</tr>

</table>


You can have as many rows as you like in a table; just make sure that the number of cells are the same in each row.

Note :There are times when a row can have less or more cells than another. You will learn about that in a later chapter.


Table Headers

Sometimes you want your cells to be table header cells. In those cases use the <th> tag instead of the <th> tag:

th stands for table header.

Example

Let the first row be table header cells:

<table>

<tr>

<th> Person 1 </th>

<th> Person 2 </th>

<th> Person 3</th>

</tr>

<tr>

<td> Emil </td>

<td> Tobias </td>

<td> Linus</td>

</tr>

<tr>

<td> 16 </td>

<td> 14 </td>

<td> 10</td>

</tr>

</table>


By default, the text in <th> elements are bold and centered, but you can change that with CSS.

Try It Your Self

Sign Up For New
Update

HTML Basic
  1. HTML Basic
  2. HTML Element
  3. HTML Attributes
  4. HTML Headings
  5. HTML Paragrapha
  6. HTML Tables
  7. HTML Lists
HTML Advance
  1. HTML Div
  2. HTML Classes
  3. HTML Id
  4. HTML Buttons
  5. HTML Iframes
  6. HTML Symbols
  7. HTML Emojis