Hi,

I have a table in my web page. I want to arrange the margins very close to sides (left, right, above, below). Because, table is wide i cant see some columns when i print it off.

How do i do this? Is it with HTML or CSS? If any, please code for it.

Thanks

Dani AI

Generated

Good call, was right to point you at print CSS and is correct that a separate print stylesheet is the cleanest way to control printed output. In short: use a print stylesheet, set page margins with an @page rule, switch to landscape for wide tables, and tighten table padding and font-size for print.

A minimal example you can put in a print stylesheet (or inside a @media print block) to push content closer to the paper edge:

@page {
  size: A4 landscape;
  margin: 5mm;
}

@media print {
  html, body { margin: 0; padding: 0; }
  table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  table th, table td { padding: 2px; }
  /* optional: hide non-essential columns for print */
  /* table td:nth-child(4), table th:nth-child(4) { display: none; } */
}

Note: printer hardware and browser print dialogs can enforce minimum non-printable margins, so CSS may not get you all the way to the paper edge. Test by printing to PDF first, try landscape and “fit to page” scaling, or use borderless printing if your printer supports it. For deeper details on page rules and size, see @page on MDN.

Recommended Answers

All 2 Replies

1: support question needs to go in the proper area to get the most out of this site
2: no one here will do it for you, we are here to help you figure it out
3:google search "css" print margins

You probably need a separate print style sheet. Google that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.