I want to print a table in chrome. The styles applied on table header are not being applied if a single row goes beyond the page and the header is repeated for it.
I have a very large value for the row and which made it go beyond a page and repeat the header in next page which doesn't have styles applied properly.
Reference image:
here background color is not applied for the next page header
code url: https://drive.google.com/file/d/1iAKsBQ82J24r0TJaR9pMiFOtBNax7idq/view?usp=sharing
code:
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
border: 1px solid #dddddd;
text-align: left;
color: red;
}
thead{
color: red;
background-color: blue;
}
tr:nth-child(odd) {
background-color: #dddddd;
}
@media print{
thead{
color: red !important;
background-color: blue !important;
}
}
</style>
</head>
<body>
<h2>HTML Table</h2>
<table>
<thead>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</thead>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma
</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
<tr>
<td>Island Trading</td>
<td>Helen Bennett</td>
<td>UK</td>
</tr>
<tr>
<td>Laughing Bacchus Winecellars</td>
<td>Yoshi Tannamuri</td>
<td>Canada</td>
</tr>
<tr>
<td>Magazzini Alimentari Riuniti</td>
<td>Giovanni Rovelli</td>
<td>Italy</td>
</tr>
</table>
</body>
</html>