Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML Table
Table

Table element creates a table, it composed of cells and each cell is composed of row and column, elements used in table are


  • <tr> stands for table row
  • <th> stands for table heading
  • <td> stands for table data
  • <caption> used for name or caption
Syntax

<table>
<tr>
<th>Table Heading<th>
<th>Table Heading<th>
</tr>
<tr>
<td>Table Data<td>
<td>Table Data<td>
</tr>
</table>


You can use table element any where within an HTML document.


Example

Name Caste
Hyder Abbasi
Table Caption
Example

Students
Name Caste
Ali Abbasi
Attributes
  • Border
  • Rowspan
  • Column span
Border

Border attribute creates boder around table.


Example

Students Table
Name Caste
Zeeshan Abbasi
Rowspan

In table row span combine all rows and make it one, table cells can be spanned by row span. This attribute is applied to <th> and <td>


Example

Students table
Name Zulfiqar
Number 1234567891011
1234567893321
Column span

In table column span combines all columns and make them one, table cells can be spanned by colspan. This attribute is applied to <th> and <td>


Example

Customers Table
Name Cell Phones
Aslam QMobile Samsung

Table is a pair tag and output of table is a table like you can see in above examples.


Practice Task

Open notepad or any other text editor, follow the following points.


  • Select any data
  • create a table
  • Give width of 100% to table

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

Employee Table
Name Number
Abbas 123456789123
Salam 567456789123
Zeeshan 121453456789

Don't forget table is non empty element which means it always comes in pair.