@page { size: A4; margin: 0; } @media print { body { margin: 0; border: none; } } @media screen { body { margin: 5mm; border: 1px solid #aaa; } } html, body { width: 210mm; height: 297mm; box-sizing: border-box; } body { display: flex; flex-direction: column; padding: 6mm 6mm 6mm 12mm; } header { display: flex; justify-content: space-between; } table#meta { margin: 8mm 0; width: 100%; } table#meta td { padding: .5mm 2mm; } table#meta td:nth-child(odd) { text-align: right; font-style: italic; } table#attendance { flex-grow: 1; width: 100%; height: 100%; transform: rotate(180deg); /* Hack for rotating a table by 270 degrees */ writing-mode: vertical-rl; /* and scaling it relatively to page size. */ border-collapse: collapse; } table#attendance th, table#attendance td { border: 1px solid #000 } table#attendance td { min-height: 5mm; width: 8mm; } table#attendance tr:nth-child(1) { background-color: #ddd; }