Context:
- I'm trying to make a webpage that is exactly 210mm wide and 297mm tall, because I want it to be perfectly printed on an A4-type paper sheet.
- However, the webpage automatically gets small left and top margins that result in the right portion of the page being cut when printed.
- These borders are painted in pink in the screenshot below. The other colors are elements of the page that I wrote code for them to exist. They are correct.
- I'm using Firefox 129.0.2 (64-bits) on Windows 10 22H2.
Question: how these margins are being generated? How can I get rid of them?
CSS:
<style>
<!-- Início: configuração A4 -->
html body {
box-sizing: border-box;
width:210mm;
height:297mm;
}
div.page {
background-color: green;
box-sizing: border-box;
width:210mm;
height:297mm;
page-break-after: always;
border: 1px solid black;
}
<!-- Fim: configuração A4 -->
tr:hover {background-color: #D6EEEE;}
table{
width:100%;
}
table tbody tr th {
text-align: left;
}
table tbody tr td time {
float: right;
}
h1, h2, h3, h4, h5, h6 {
text-align: center;
background-color: Grey;
color: white;
}
table thead tr {
text-align: center;
background-color: DarkGrey;
}
section {
border-top : 1px solid black;
border-bottom: 1px solid black;
}
</style>
HTML:
<body>
<div name="front" class="page">
<section>
<h1>Stack Exchange</h1>
<p>Lorem ipsum</p>
</section>
</div>
</body>