HTML TABLES :
The HTML tables allows to arrange data like text, images, links, other tables, etc. into rows and columns of cells.
1. Tables are defined with the <table> tag.
2. Tables are divided into table rows with the <tr> tag.
3. Table rows are divided into table data with the <td> tag.
4. A table row can also be divided into table headings with the <th>.
Example for HTML Tables :
<html>
<head>
<style>
table, th, td{ border: 2px solid red;
border-collapse: collapse; }
</style>
</head>
<body>
<table style="width:50%">
<tr>
<th>Boys</th>
<th>Girls</th>
</tr>
<tr>
<td>Kunal</td>
<td>Shital</td>
</tr>
<tr>
<td>Nitin</td>
<td>Neha</td>
</tr>
<tr>
<td>Anshul</td>
<td>Prachi</td>
</tr>
</table>
</body>
</html>
table, th, td{ border: 2px solid red;
border-collapse: collapse; }
</style>
</head>
<body>
<table style="width:50%">
<tr>
<th>Boys</th>
<th>Girls</th>
</tr>
<tr>
<td>Kunal</td>
<td>Shital</td>
</tr>
<tr>
<td>Nitin</td>
<td>Neha</td>
</tr>
<tr>
<td>Anshul</td>
<td>Prachi</td>
</tr>
</table>
</body>
</html>
Output:
Boys | Girls |
---|---|
Kunal | Shital |
Nitin | Neha |
Anshul | Prachi |
Cell padding :
Cell padding specifies the space between the cell content and its borders, If not specified a padding, the table cells will be displayed without padding.
BORDER SPACING :
Border spacing specifies the space between the cells.
CAPTION :
To add a caption to a table, use the <caption> tag.
TABLE COLOR
To define color for the borders, and the text and background color of elements