How to create a table in HTML:
Let's discuss how to create a table in HTML
A table in HTML can be created by using <table> tag. The table tag defines a table for multidimensional data arranged in row and columns.
Tables are commonly used to display all manner of data, such as timetables, financial reports, and sports results. To work with tables, we need to start thinking in a grid of rectangle.
Each rectangle is known as a cell. A row is made up of a set of cells on the same line from left to right, while a column is made up of a line of cells going from top to bottom.
Inside the <table> element, the table is written out row by row. A row is contained inside an <tr> element -which stands for table row, each cell is then written inside the row element using an <td> element which stands for table data. And Creates table headings; just like table data but usually bold and centered vertically and horizontally using <th> element -which stands for a table heading.
Inside the <table> element, the table is written out row by row. A row is contained inside an <tr> element -which stands for table row, each cell is then written inside the row element using an <td> element which stands for table data. And Creates table headings; just like table data but usually bold and centered vertically and horizontally using <th> element -which stands for a table heading.
ALSO READ: List in HTML
<Table> Attributes:
The <table> tag allows many optional attributes that specify the properties of the entire table. The most important attributes of the table are as follows:
Width |
Used to set the width of the table and it must be a percentage value. |
Cell spacing
|
Used to set the distance between cells. The value should be in pixels. |
Border
|
Used to set the thickness of the border. |
Cell padding.
|
Used to set the distance between the border and content of cells |
Width |
This attribute is used to describe the desired width of this table, either as an absolute width in pixels, or a percentage of document width.
|
Height |
This attribute describes the height of the table, either as a particular pixel value or as a percentage of the display window.
|
Align |
It allows a table to be aligned to the left or right of the page, allowing text to flow around the table.
|
bgcolor |
It allows the background color of the table to be specified, using either the specified color name or an rrggbb hex triplet.
|
Border color |
This attribute used to set the border color of the table.
|
ALSO READ: Structure of HTML document
Example
<html>
<head>
<title>table example</title>
</head>
<body>
<center>
<center>
<b>Name of the student:</b> neha<br>
<b>department:</b> computer application<br>
<b>college: </b> MKJC<br>
<table border =6 width=60% align="center" bgcolor="cyan" bordercolor="red">
<tr>
<th>Subject</th>
<th>Internal Mark</th>
<th>External Mark</th>
</tr>
<tr>
<td>programming in c</td>
<td align=center>20</td>
<td align=center>70</td>
</tr>
<tr>
<td>programming in c++</td>
<td align=center>22</td>
<td align=center>71</td>
</tr>
<tr>
<td>programming in java</td>
<td align=center>24</td>
<td align=center>74</td>
</tr>
</table>
</center>
</center>
</body>
</html>
The output of this coding is:
No comments:
Post a Comment