Programming Table Attributes in HTML
Programming Table Attributes in HTML
table, td, th {
border: 1px solid;
}
OUTPUT
• The output results for both the methods using inline border
attribute or CSS border property are same as the following :
• Note- In the above example we have separate borders for all the cells
of one table and collapsed of another. Collapsed borders can be
achieved by using the border-collapse property of CSS :
table, td, th {
border: 1px solid;
border-collapse: collapse;
}
OUTPUT
• Using CSS border-collapse property, we have collapsed different
borders of all the cells into a single border.
table, td, th {
border: 1px solid;
border-collapse: collapse;
}
The Cell Padding
HTML Table Cell Padding
• If there should be some gap between borders and nested data in the
table, this gap is known as cell padding.
• Apply the gap by using padding property of CSS as follows.
td, th {
padding: 1.5rem;
}
• Output
• caption is assigned to the table i.e "New Employees Record", using
the <caption> tag.
HTML table with Background Color
HTML table with Background Color
• We can add background color to a particular cell, row
or to a complete table.
• This can be done by CSS background-color property
or by HTML inline attribute.
HTML table with Background Color
<table>
• Using HTML Inline Attribute <tr>
<th>Name</th>
Add bgcolor="#$$$$$$" attribute to <th>Jobs</th>
any element of the table in which <th>Working Experience</th>
</tr>
you want to add background color. <tr>
<td>John</td>
<td>Software Engineer</td>
<td>5 Years</td>
</tr>
<tr id="eligible" bgcolor="#0bb31e">
<td>Ale</td>
<td>Senior Web developer</td>
<td>2 Year</td>
</tr>
</table>
HTML table with Background Color
• Using CSS background-color Property Simply just add
this background-color property to your css code for the element
which you want to color. #eligible {
background-color: #0bb31e;
}
• Output
<table>
<tr>
The <tr id=“”> <th>Name</th>
<th>Jobs</th>
<th>Working Experience</th>
• An id on a <tr> tag assigns an </tr>
identifier to the table row. <tr>
<td>John</td>
• The identifier must be unique across <td>Software Engineer</td>
the page. <td>5 Years</td>
</tr>
<tr id="eligible" bgcolor="#0bb31e">
<td>Ale</td>
<td>Senior Web developer</td>
<td>2 Year</td>
</tr>
</table>
End