All HTML Table Attributes

Hi developers, in this article I am going to share all HTML Table attributes with you that you will use while creating HTML tables in your web project. Based on different layout.

So, here is the list of All HTML Table Attributes with explanation and code example so that you can learn All HTML Table Attribute by real example:

border

The border attribute in HTML table is used to add a border on table. In real example it’s make a look of HTML table like a real table including rows and columns.

Code Example

<table border=”1“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

cellpadding

In HTML table cellpadding attribute is used to specify the space between the cell content and the cell borders.

Code Example

<table border=”1cellpadding=”10“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

cellspacing

In HTML table the cellspacing attribute is used to specify the space between the table cells.

Code Example

<table border=”1cellspacing=”20“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

width

As the name suggests itself, the width HTML table attribute is used to adjust or set the width of table.

Code Example

<table border=”1width=”500px“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

height

The height table attribute in HTML is used to adjust or set the height of table.

Code Example

<table border=”1height=”200px“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

summary

This HTML Table attribute provides a description or summary of HTML table’s purpose and structure. It working something like a ‘tooltip’.

Code Example

<table border=”1summary=”DesignWithRehana Information“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

align

This HTML Table attribute specify the horizontal alignment of the table on the web page.

Code Example

<table border=”1align=”center“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

bgcolor

bgcolor HTML Table attribute is used to set the background color of the table.

Code Example

<table border=”1bgcolor=”skyblue“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

colspan

The colspan table attribute is used to specify the number of columns a cell should span.

Code Example

<table border=”1“>
    <tr>
        <td colspan=”2“> Rehana Information </td>
    </tr>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td> Frontend Developer </td>
    </tr>
</table>

rowspan

The rowspan table attribute is used to specify the number of rows a cell should span.

Code Example

<table border=”1“>
    <tr>
        <td> Name </td>
        <td> Role </td>
    </tr>
    <tr>
        <td> Rehana </td>
        <td rowspan=”2“> Frontend Developer </td>
    </tr>
    <tr>
        <td> Raju </td>
    </tr>
</table>

3 thoughts on “All HTML Table Attributes”

Leave a Comment