How Do You Create a Tables In Html Code

admin_img Posted By Bajarangi soft , Posted On 29-09-2020

HTML tables allow web developers to arrange data into rows and columns,Each table row is defined with a 'tr'tag,Each table header is defined with a 'th' tag,Each table data/cell is defined with a 'td' tag,'th' elements are bold and center, 'td' elements are regular and left-aligned.

Table data

1.Create a Table in HTML

<!DOCTYPE html>
<html>
<head>
    <style>
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
        }
        th, td {
            padding: 15px;
        }
        #t01{
            background-color: antiquewhite;
            width:90%;
        }

#t01 caption{
    font-size: 30px;
}

    </style>
</head>
<body>

<h2>TABLE </h2>

<table style="width:90%">
    <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Age</th>
    </tr>
    <tr>
        <td>Jill</td>
        <td>Smith</td>
        <td>50</td>
    </tr>
    <tr>
        <td>Eve</td>
        <td>Jackson</td>
        <td>94</td>
    </tr>
    <tr>
        <td>John</td>
        <td>Doe</td>
        <td>80</td>
    </tr>
</table>
<br>
<h2>TABLE DATA</h2>
<table id="t01">
    <caption>employess data</caption>
    <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Age</th>
    </tr>
    <tr>
        <td>Jill</td>
        <td>Smith</td>
        <td>50</td>
    </tr>
    <tr>
        <td>Eve</td>
        <td>Jackson</td>
        <td>94</td>
    </tr>
    <tr>
        <td>John</td>
        <td>Doe</td>
        <td>80</td>
    </tr>
</table>
</body>
</html>
1.Create a Table in HTML with Rowspan and colspan
<!DOCTYPE html>
<html>
<head>
    <style>
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
            background-color: beige;
        }
        th, td {
            padding: 5px;
            text-align: left;
            padding:15px;
        }
        #t01{
            width:90%;
            background-color: antiquewhite;
        }
    </style>
</head>
<body>

<h2>COL SPAN</h2>
<p>To make a cell span more than one column, use the colspan attribute.</p>

<table style="width:90%">
    <caption>Table data</caption>
    <tr>
        <th>Name</th>
        <th colspan="2">Telephone</th>
    </tr>
    <tr>
        <td>Bill Gates</td>
        <td>55577854</td>
        <td>55577855</td>
    </tr>
</table>

<br>
<h2>ROW SPAN</h2>
<table id="t01">
    <tr>
        <th>Name:</th>
        <td>Bill Gates</td>
    </tr>
    <tr>
        <th rowspan="2">Telephone:</th>
        <td>55577854</td>
    </tr>
    <tr>
        <td>55577855</td>
    </tr>
</table>

</body>
</html>

Related Post