The table tag a very important tag in the HTML language. A table consists of rows and columns. The data in a table is more readable and easy to understand. In the table, we can present the data in sort form. There are three main elements in HTML for building tables. These are the tags <th>, <tr> and <td> is used in the table tag.
The <th> is used to define the table heading. The <tr> is used to define the table rows and the <td> is used to define the table column. The table tag is used to define a table. <tr> tag is used to define a row in a table and <td> tag is used to define a data cell. <th> tag is used to define the header row of the table.
Attributes of Table Tag
Attributes | Description |
Align | It specifies the horizontal alignment of the table. Possible alignments are left, right, and center. |
Valign | It specifies the vertical alignment of the table. Possible alignments are top, bottom, and middle. |
Width | It specifies the width of the table. It can be given as the number of pixels or as a percentage relative to the screen. |
Border | It specifies the thickness of the border of the table. |
Cellpadding | It specifies the distance between data in the cell and cell boundaries. |
Cellspacing | It specifies the spacing between adjacent cells of the table. |
col span | It specifies the number of columns for a cell. It is used inside or tags. A cell may consist of many columns. |
Rowspan | It specifies the number of rows for a cell. It is used inside or tags. A cell may consist of many rows. |
The <tr> tag
The <tr> tag is used to create a row in the table tag. TR stands for table row.
Attributes of <tr> tag:
Some important attributes of <tr> tag are as follows:
Attribute | Description |
Align | It specifies the horizontal alignment of the row. Possible alignments are left, right and center |
Bg-color | Bg-color It specifies the color of the background for the row |
Valign | It specifies the vertical-align the content of the row. The possible values are top, middle or bottom |
The <td> tag
The <td> tag is used to create cells in the row of a table tag. TD stands for table data. You can say that this tag is used to create the column fo the table tag.
Attributes of <td> tag
Some important attributes of <td> tag are as follows:
Attributes | Description |
Align | It specifies the horizontal alignment of the cell. Possible alignments are left, right and center. |
Background | It specifies the background image inside of the table cell |
Bg-color | It specifies the color of the background of the cell |
col span | It stretches the length of the cells to 2 or more cell lengths |
Height | It specifies the height of the cell in pixels |
nowrap | It locks the content so that it all stays on the same line |
Rowspan | It stretches the height of the cells to 2 or more cells |
Valign | It specifies the vertical alignment of the content of the cell. The possible values are top, middle or bottom |
Width | It specifies the width of the actual cell in pixels or percentage |
Example
<!DOCTYPE html>
<html>
<head>
<title>table in HTML</title>
</head>
<body>
<h3>Tables in HTML</h3>
<table border="1" width="200px" align="center">
<tr>
<th>Roll NO.</th>
<th>Marks:</th>
</tr>
<tr>
<td>1</td>
<td>89</td>
</tr>
<tr>
<td>2</td>
<td>91</td>
</tr>
<tr>
<td>3</td>
<td>78</td>
</tr>
</table>
</body>
</html>
Output
Reference
If you want to learn more about HTML or image tag then visit the official website: Visit
Visit the HTML tutorial list. And make strong your HTML concept. Click here. wuschools.com is always written about the HTML concept for the HTML lover. Ang writes about how HTML makes your life easy if you are a web site developer. We help you to continue your learning.
Si desea iniciar sesión para escribir el artículo aquí, contácteme a través de Gmail. info@wuschools.com
This web site can be a stroll-through for the entire info you wished about this and didn’t know who to ask. Glimpse right here, and also you’ll definitely discover it.