019 HTML Tables


019 HTML Tables

Defining HTML Tables
An HTML Table with a Border Attribute
An HTML Table with Collapsed Borders
An HTML Table with Cell Padding
HTML Table Headings
An HTML Table with Border Spacing
Table Cells that Span Many Columns
Table Cells that Span Many Rows
An HTML Table With a Caption
Different Styles for Different Tables
examples


<!DOCTYPE html>
<html>
<body>

<table style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</table>

</body>
</html>

===

<table border="20" style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>


======
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 5px solid black;
    border-collapse: collapse;
}

th, td {
    padding: 15px;
}

</style>
</head>
<body>

<table style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</table>

</body>
</html>

====

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

th {
    text-align: left;
}
table {
    border-spacing: 15px;
}


</style>
</head>
<body>

<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>       
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</table>

</body>
</html>

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

<table style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</table>

<p>Try to change the border-spacing to 5px.</p>

</body>
</html>

====
<style>
table, th, td {
    border: 1px solid black;
    padding: 5px;
}

</style>


<table style="width:100%">
<caption>Monthly savings</caption>
  <tr>
    <th>Name</th>
    <th colspan="2">Telephone</th>
  </tr>
  <tr>
    <td>Bill Gates</td>
    <td>555 77 854</td>
    <td>555 77 855</td>
  </tr>
</table>

<table style="width:100%">
  <tr>
    <th>Name:</th>
    <td>Bill Gates</td>
  </tr>
  <tr>
    <th rowspan="2">Telephone:</th>
    <td>555 77 854</td>
  </tr>
  <tr>
    <td>555 77 855</td>
  </tr>
</table>

======
<!DOCTYPE html><html><head>
<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
table#t01 {
    width: 100%;   
    background-color: #f1f1c1;
}
</style>
</head><body>

<table style="width:100%">
  <tbody><tr>
    <th>First Name</th>
    <th>Last Name</th>       
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</tbody></table>

<br>

<table id="t01">
  <tbody><tr>
    <th>First Name</th>
    <th>Last Name</th>       
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</tbody></table>



</body></html>

=====

<!DOCTYPE html>
<html>
<head>
<style>
table {
    width:100%;
}
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
table#t01 tr:nth-child(even) {
    background-color: #eee;
}
table#t01 tr:nth-child(odd) {
   background-color:#fff;
}
table#t01 th    {
    background-color: black;
    color: white;
}
</style>
</head>
<body>

<table>
  <tr>
    <th>First Name</th>
    <th>Last Name</th>       
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
</table>

<br>

<table id="t01">
  <tr>
    <th>First Name</th>
    <th>Last Name</th>       
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
   <tr>
    <td>Jill</td>
    <td>Smith</td>       
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>       
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>       
    <td>80</td>
  </tr>
 
</table>

</body>
</html>

====


تابع  الشرح التفصيلى  للامثلة فى الفيديو المرفق









Chapter Summary
Use the HTML <table> element to define a table
Use the HTML <tr> element to define a table row
Use the HTML <td> element to define a table data
Use the HTML <th> element to define a table heading
Use the HTML <caption> element to define a table caption
Use the CSS border property to define a border
Use the CSS border-collapse property to collapse cell borders
Use the CSS padding property to add padding to cells
Use the CSS text-align property to align cell text
Use the CSS border-spacing property to set the spacing between cells
Use the colspan attribute to make a cell span many columns
Use the rowspan attribute to make a cell span many rows
Use the id attribute to uniquely define one table

المشاركات الشائعة