Here's a complete HTML solution for a striped table with borders that's optimized for printing:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Printable Striped Table</title>
<style>
@media print {
body * {
visibility: hidden;
}
.print-table, .print-table * {
visibility: visible;
}
.print-table {
position: absolute;
left: 0;
top: 0;
width: 100%;
}
}
.print-table {
width: 100%;
border-collapse: collapse;
}
.print-table th, .print-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
.print-table th {
background-color: #f2f2f2;
}
.print-table tr:nth-child(even) {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<table class="print-table">
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
<tr>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
</tr>
<tr>
<td>Row 4, Cell 1</td>
<td>Row 4, Cell 2</td>
<td>Row 4, Cell 3</td>
</tr>
</tbody>
</table>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Printable Striped Table</title>
<style>
@media print {
body * {
visibility: hidden;
}
.print-table, .print-table * {
visibility: visible;
}
.print-table {
position: absolute;
left: 0;
top: 0;
width: 100%;
}
}
.print-table {
width: 100%;
border-collapse: collapse;
}
.print-table th, .print-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
.print-table th {
background-color: #f2f2f2;
}
.print-table tr:nth-child(even) {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<table class="print-table">
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
<tr>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
</tr>
<tr>
<td>Row 4, Cell 1</td>
<td>Row 4, Cell 2</td>
<td>Row 4, Cell 3</td>
</tr>
</tbody>
</table>