I am using a separate style-sheet for printing.
Is it possible to set right and left margins in the style-sheet which set the print margin? (i.e. margin on paper)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should use
cmormmas unit when you specify for printing. Using pixels will cause the browser to translate it to something similar to what it looks like on screen. Usingcmormmwill ensure consistent size on the paper.For font sizes, use
ptfor the print media.Note that setting the margin on the body in css style will not adjust the margin in the printer driver that defines the printable area of the printer, or margin controlled by the browser (may be adjustable in print preview on some browsers)… It will just set margin on the document inside the printable area.
You should also be aware that IE7++ automatically adjusts the size to best fit, and causes everything to be wrong even if you use
cmormm. To override this behaviour, the user must select ‘Print preview’ and then set the print size to100%(default isShrink To Fit).A better option for full control on printed margins is to use the
@pagedirective to set the paper margin, which will affect the margin on paper outside the html body element, which is normally controlled by the browser. See http://www.w3.org/TR/1998/REC-CSS2-19980512/page.html.This currently works in all major browsers except Safari.
In Internet explorer, the margin is actually set to this value in the settings for this printing, and if you do Preview you will get this as default, but the user can change it in the preview.
Related answer:
Disabling browser print options (headers, footers, margins) from page?