Matt Wilson Matt Wilson - 1 year ago 62
HTML Question

Specifying phyiscal size in CSS (e.g. 2 inches) when printing a web page

Is there a reliable way to specify physical dimensions in CSS such that when the page is printed, my elements are at a specific size and position on the printed page?

I see that CSS has units for in and cm, but (not surprisingly) neither Firefox nor Chrome actually printed the box at 2x2 inches when I did the following:

.test {
width: 2in;
height: 2in;
border: solid 1px #aaa;

Am I being too optimistic hoping that there is some way of specifying the size and having the browser adjust it's printing size based on the resolution of the printer etc?


Answer Source

Try adding margin: 0; padding: 0 to avoid any extra spacing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download