Questions tagged [print-css]

When printing an HTML document, these CSS stylerules are applied. Their purpose is to improve the print result e.g. by hiding banners and ads, correcting colors and font-sizes and generally adjusting the layout for printing.

CSS gives the possibility to provide styles for different media-types by adding the media-attribute to the style tag.

When triggering the print-function, browsers apply the styles defined for the mediatype print.

<!-- Including an external print stylesheet -->
<link rel="stylesheet" type="text/css" href="print.css" media="print" />

<!-- Declaring print styles via the style tag -->
<style type="text/css" media="print">
   /* styles */
</style>

When printing websites, special treatment of several HTML-Elements is required in order to achieve a decent print-result.

The most obvious problem might be links, which are not clickable (and thus are useless) when printed. However, the href-attribute could be made visible with the following print-only css-declaration:

a:after { content: " (" attr(href) ")"; font-size: 80%; }

Also colors, fonts and floats might need to be adjusted, so it is advised to provide CSS-styles for printing.

useful links:

Article about print stylesheets on Smashing Magazine

68 questions
298
votes
7 answers

Need to remove href values when printing in Chrome

I'm attempting to customize the print CSS, and finding that it prints links out with the href value as well as the link. This is in Chrome. For this HTML: Google It prints: Google (http://www.google.com) And I…
Chris Gratigny
  • 3,143
  • 2
  • 14
  • 7
68
votes
9 answers

How to see the print media CSS in Firebug?

Firebug is an excellent tool to to show a screen media CSS for some HTML element, but is there a way to look at the print media CSS too? Or is there any other tool to see the print media CSS?
Janko Mivšek
  • 3,864
  • 3
  • 21
  • 29
33
votes
8 answers

How do I Make Firefox Print a Background-Color Style?

I have some simple CSS: #someElement { background-color:black; color:white; } It looks ok in the browser, but when I go to print it in Firefox it comes out as black text on a white background. I imagine this is some sort of ink-saving…
machineghost
  • 28,573
  • 26
  • 128
  • 197
33
votes
4 answers

How to make HTML pages print at a consistent size from Chrome?

I'm designing a set of HTML pages to be printed, and I want elements of the pages to end up the same scale as each other. For example, there's a class of div whose width is defined as 200px wide appears on each of several pages. I want it to appear…
AlexC
  • 3,391
  • 3
  • 23
  • 25
24
votes
3 answers

Print table footer at the very bottom on last page

I am using a table to create a footer on every page (works in Firefox, that's enough). A JS Fiddle: https://jsfiddle.net/j9k2xzze/ (right click on the output pane -> This Frame -> Open Frame in New Tab. Then Print Preview will function as…
LeMike
  • 3,067
  • 4
  • 19
  • 35
13
votes
2 answers

I'm trying to use a print.css to print one div per page, and I'm failing

An example of my code is this:
This div needs to be on one page.
This div needs to print on a separate page.
I have a couple divs like above, and I need each div to be on it's own page when…
Zach
  • 161
  • 2
  • 10
12
votes
3 answers

Printing fieldsets in firefox

I've been adding some new css to an existing project (using media="print") in the page header. It's going smooth and (for once!) IE is giving nice, expected results, but Firefox does not... The problem is that I have a fieldset which contains a lot…
Dave
  • 6,525
  • 2
  • 30
  • 35
12
votes
3 answers

How to make page border in print CSS for every single page

I have a long HTML to print. Page is ready for printing but I need to border every single page. I added body { border:2px #666 solid; padding:5px; } in CSS code. HTML view is nice but print view is not. Because border-bottom is not showing first…
Yasin Yörük
  • 1,212
  • 3
  • 21
  • 48
11
votes
3 answers

Page break is not working with the tbody issue

I am generating a print report using table in twitter-bootstrap layout. The page has multiple tbody inside a table; While Printing the page it requires a page-break-after each tbody To do so, I have applied print-css @media print { tbody{ …
Suresh Karia
  • 14,742
  • 18
  • 63
  • 83
10
votes
2 answers

CSS: Disable Header & Footer From Print Preview Chrome

one of my application is web based POS(Point Of Sale). so while printing invoices in chrome. the page header and the page footer automatically inserted by the browser that I want to supress via the page and without user intervention.. I applied some…
Niks Jain
  • 1,549
  • 5
  • 25
  • 51
8
votes
1 answer

Print preview squishing content

I'm trying to get print preview to print for me in the way that I want it to using the @page directive in CSS. For some reason, no matter what my page margins are set to, the content gets squished, even if the numbers are supposedly exact. Here is…
Seiyria
  • 1,941
  • 3
  • 28
  • 50
8
votes
2 answers

Chrome: Print preview differs from simulate CSS media print

I am having an issue when I print my page in Chrome 26 where tables appear with grey background colour. When I view the page in chrome with simulated CSS media print it looks fine When printing in Safari everything works fine. Anyone knows how to…
Christian R
  • 1,525
  • 3
  • 13
  • 17
5
votes
3 answers

Google Chrome handling page breaks differently on different computers

I am finalizing a print stylesheet for a rendered report in a web application and have been notified of some printing issues on different machines. When adding a page break before my header, I am noticing a ton of added white space, which seems tied…
rahlf23
  • 7,918
  • 3
  • 14
  • 44
5
votes
1 answer

Firefox print CSS - Extra blank page on A4 page

I created a simple print CSS which generates an A4 page.