how create table in html

creating a table in html page is a easy way to keep data in rows & coloums.

The HTML tables are created using the tags <table> <tr> <td>.

here are simple table:

<!DOCTYPE html>
<html>
<head>
<title>Header</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>City</th>
</tr>
<tr>
<td>Tony Tester</td>
<td>New York</td>
</tr>
<tr>
<td>Harry Hacker</td>
<td>Paris</td>
</tr>
</table>
</body>
</html>

Table Heading

Table heading can be defined using <th> tag
Header will placed between <th> </th> tags
table headings are bold and centered.

Data Cell

A table data/cell is defined with the <td> tag

Table with Caption

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
</style>
</head>
<body>

<table style="width:100%">
  <caption>Employees Name</caption>
  <tr>
    <th>Fname</th>
    <th>Lname</th>
  </tr>
  <tr>
    <td>Raju</td>
    <td>Kumar</td>
  </tr>
  <tr>
    <td>Syed</td>
    <td>Ahamed</td>
  </tr>
</table>

</body>
</html>

Table Tags

    <table> define a table
    <tr>  define a table row
    <td>  define a table data
    <th>  define a table heading
    <caption>  define a table caption
    
READ  html simple login form

Leave A Comment

Your email address will not be published. Required fields are marked *