Html Table
This tutorial will help you to learn Html Table and It is very easy to learn .You just follow my tutorial .Open your notepad and write code ,save it and see it in browser step by step.
Lets Start.
Html Table
Table is
used to store data in rows and columns. We will use example how can create a
table in html
Example
<html>
<body>
<h2>Basic HTML Table</h2>
<table style="width:100%">
<tr>
<th>Name</th>
<th>FatherName</th>
<th>Age</th>
</tr>
<tr>
<td>Ali</td>
<td>Abbas</td>
<td>50</td>
</tr>
<tr>
<td>Aslam</td>
<td>Ashraf</td>
<td>45</td>
</tr>
<tr>
<td>Mohsin</td>
<td>Ali</td>
<td>40</td>
</tr>
</table>
</body>
</html>
<table>
is used to define table in html. <tr> tag is used for table row in html.
Table header
is defined by <th> and <td> is used to define table data.
Table Border
Now we are
going to add border in html table. For this we use html style.
<!DOCTYPE html>
<html>
<head>
<style>
table, th,
td {
border: 1px solid black;
}
</style>
</head>
<body>
<h2>Basic HTML Table</h2>
<table style="width:100%">
<tr>
<th>Name</th>
<th>FatherName</th>
<th>Age</th>
</tr>
<tr>
<td>Ali</td>
<td>Abbas</td>
<td>50</td>
</tr>
<tr>
<td>Aslam</td>
<td>Ashraf</td>
<td>45</td>
</tr>
<tr>
<td>Mohsin</td>
<td>Ali</td>
<td>40</td>
</tr>
</table>
</body>
</html>
Browser Result:
We use border
property in html style to define border in html table.
Collapsed Borders
For collapsed
borders, we will use border-collapse property in html syles.
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<h2> HTML Table-Collapsed Borders</h2>
<table style="width:100%">
<tr>
<th>Name</th>
<th>FatherName</th>
<th>Age</th>
</tr>
<tr>
<td>Ali</td>
<td>Abbas</td>
<td>50</td>
</tr>
<tr>
<td>Aslam</td>
<td>Ashraf</td>
<td>45</td>
</tr>
<tr>
<td>Mohsin</td>
<td>Ali</td>
<td>40</td>
</tr>
</table>
</body>
</html>
Browwer Result:
I hope you like the post ,please don't hesitate to share my post to your friends. Thanks!!!
Comments
Post a Comment