CSS Properties: How to set border collapse initial answer?
Solution:
HTML Code:
<!DOCTYPE html><!-- Declaration of HTML5 document type -->
<html>
<head>
<title>How to set border collapse initial answer</title><!-- Title of the HTML document -->
<style>/* CSS style start*/
table#mytable {
border-collapse:initial; /* Sets the border-collapse property to its initial value for the table with id "mytable" */
}
table, td, th {
border: 1px solid red; /* Sets a red solid border with 1px width for table, td, and th elements */
}
</style>
</head>
<body>
<table id="mytable"><!-- Start of the table with id "mytable" -->
<tr><!-- Start of the table row -->
<th>First Name</th><!-- Table header cell containing "First Name" -->
<th>Last Name </th><!-- Table header cell containing "Last Name" -->
</tr><!-- End of the table row -->
<tr><!-- Start of another table row -->
<td>Jack</td><!-- Table data cell containing "Jack" -->
<td>Bell</td><!-- Table data cell containing "Bell" -->
</tr><!-- End of the table row -->
<tr><!-- Start of another table row -->
<td>Peter</td><!-- Table data cell containing "Peter" -->
<td>Jhon</td><!-- Table data cell containing "Jhon" -->
</tr><!-- End of the table row -->
</table><!-- End of the table with id "mytable" -->
</body>
</html>
Explanation:
- This HTML document sets the border collapse to its initial value.
- The CSS style block defines the style for the table with id "mytable" and its cells (td and th).
- border-collapse:initial; specifies that the table border-collapse property should revert to its initial value.
- border: 1px solid red; sets a red solid border with 1px width for the table, td, and th elements.
- Inside the body, a table is defined with id "mytable" and three rows (tr) and two columns (th and td).
- Table header cells (th) contain "First Name" and "Last Name" respectively.
- Table data cells (td) contain names like "Jack", "Bell", "Peter", and "Jhon".
Live Demo:
See the Pen border-collapse-initial-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html-css-exercise/css-properties/border-collapse-initial-answer.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics