HTML - Tables




What is HTML tables

Tables have been useful in a number of ways as they help an individual to present the data in a proper manner.

Similar the tables which we find in HTML permit the web authors to have the data arranged either in the form of images or text or links or even other tables in the form of columns or rows of the cells.

Many of the economic, financial, and other factual research data need to be presented in a tabular form. Don’t worry, html table will help you to insert your such data in the same form as you insert them in excel sheet.

The html tables can be created by using the <table> tag. This tag uses the <tr> tag to create table rows and uses <td> tag to create data cells.

Example

<!DOCTYPE html>
<title>For Example</title>
<table class = "no-class" border="5">
    <tr>
        <th>Header</th>
        <th>Header</th>
        <th>Header</th>
    </tr>
    <tr>
        <td>Raj</td>
        <td>Rahul</td>
        <td>Reena</td>
    </tr>
    <tr>
        <td>Apple</td>
        <td>Mango</td>
        <td>Quince</td>
    </tr>
</table>

Result

For Example
Header Header Header
Raj Rahul Reena
Apple Mango Quince

Point to Remember −

  • The HTML <table> tag is used to define a table.

  • The HTML <td> tag is used to define a table data.

  • The HTML <tr> tag is used to define a table row.

  • The HTML <th> tag is used to define a table heading.

  • The HTML <caption> tag is used to define a table caption.

  • The CSS border is used to define a border property.

  • The CSS border-collapse tag is used to collapse cell borders.

  • The CSS text-align property is used to align cell text.

  • The CSS border-spacing property is used to set the spacing between cells.

  • The rowspan attribute is used to make a cell span many rows.

  • The id attribute is used to define one table uniquely.