0% found this document useful (0 votes)
5 views

HTML Tables

Uploaded by

Muthamil0593
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

HTML Tables

Uploaded by

Muthamil0593
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Tag Description

<table> Defines the table structure.


<tr> Defines a table row.
<td> Defines a table cell (data cell).
<th> Defines a table header cell (bold and centered by default).
<caption> Adds a caption/title to the table.
<thead> Groups header rows of the table.
<tbody> Groups the body (main) rows of the table.
<tfoot> Groups footer rows of the table.
<colgroup> Groups columns for applying styles.
<col> Defines attributes for specific columns in a <colgroup>.

<table border="1">
<caption>Student Grades</caption>
<tr>
<th>Name</th>
<th>Grade</th>
</tr>
<tr>
<td>John</td>
<td>A</td>
</tr>
<tr>
<td>Jane</td>
<td>B</td>
</tr>
</table>

<table border="1">
<thead>
<tr>
<th>Subject</th>
<th>Marks</th>
</tr>
</thead>
<tbody>
<tr>
<td>Math</td>
<td>90</td>
</tr>
<tr>
<td>Science</td>
<td>85</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td>175</td>
</tr>
</tfoot>
</table>

<table border="1">
<colgroup>
<col style="background-color: lightblue;">
<col style="background-color: lightgreen;">
</colgroup>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Pen</td>
<td>$1</td>
</tr>
<tr>
<td>Notebook</td>
<td>$3</td>
</tr>
</table>

HTML Table Attributes


Tag Attribute Description
<table> border Specifies the width of the table borders
(use CSS for modern styling).
cellpadding Sets the padding between the content and the cell
border.
cellspacing Sets the spacing between table cells.
width Sets the width of the table.
height Sets the height of the table.
align Aligns the table horizontally (values: left, center,
right).
bgcolor Sets the background color of the table
(deprecated).
<tr> align Aligns the content horizontally in the row (values:
left, center, right).
valign Aligns the content vertically in the row
(values: top, middle, bottom).
bgcolor Sets the background color of the row.
<td> and <th> colspan Specifies the number of columns a cell
spans.
rowspan Specifies the number of rows a cell spans.
align Aligns the content horizontally in the cell.
valign Aligns the content vertically in the cell.
width Specifies the width of the cell.
height Specifies the height of the cell.

You might also like