×

Html & Html5

The World's best Software Development Study Portal

HTML Table


An HTML table is defined with the table tag. It is used to display data in a tabular form on a web page. Data is shown in various rows and columns as required. It uses the below tags for rows and column:-



Let's understand this by the following example:


Output:




Add Border

There are 2 ways to add border in tables.

  1. By border attribute of table in HTML
  2. By border property in CSS

By border attribute

You can use border attribute of table tag in HTML to specify border.

Let's understand this by the following example:


Output:




By border property in CSS

It is now recommended to use border property of CSS to specify border in table.

Let's understand this by the following example:


Output:




Collapse Border

If you want to collapse border,use border-collapse property:

Let's understand this by the following example:


Output:




Table Caption

Caption is display above table.It provide necessary information about table.To add caption to table use caption tag.

Let's understand this by the following example:


Output:




HTML table with rowspan

Rowspan is used to make a cell span more than one row.It can apply with rowspan attribute.

Let's understand this by the following example:


Output:




HTML table with colspan

colspan is used to make a cell span more than one coloumn.It can apply with colspan attribute.

Let's understand this by the following example:


Output: