Ky -
Ky -

Reputation: 32143

Is there any way to tell a browser that your webpage is printer-friendly?

I have a webpage with a printer-specific stylesheet that I use to make sure it uses zero color ink and as little black as possible. However, there is one very important element that's not text which I need to show up: the logo, which is kept in and displayed by CSS. By default, Chrome (and probably Chromium-based browsers) does not print "Background graphics", which is any color or image brought in by a stylesheet. Is there any meta tag or other such method I can use to tell the browser that I've made sure the page is printer-friendly? I tried displaying it in an <IMG> but that proved too difficult to position.

I'm looking for something in the same vein as using <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=utf-8"/> <META CHARSET="utf-8" /> to tell it I've made this in UTF-8, or <META PROPERTY="og:locale" CONTENT="en_US" /> to tell it that this is US English, or <META NAME="viewport" CONTENT="initial-scale=1.0, user-scalable=no" /> to tell it that this is a mobile-friendly site. All these, I think, are so it doesn't have to make assumptions, and I should hope that there's a printer-friendliness tag out there.

Upvotes: 0

Views: 137

Answers (1)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201668

No, there is no way to tell a browser that your webpage is printer-friendly. If there were, it would hardly have any impact, and if it did, it would probably be misused. This is different from e.g. the tag that you describe as indicating a “mobile-friendly site”, which will just suppress the default scaling (and prevent user-scalability, which is hardly friendly to anyone).

What you can do is to specify that some style sheets are to be applied for print media only. But this simply restricts their effect to print media.

You can also use <link rel="alternate" media="print" href="..."> to specify an alternate version of the page for print. But this will, at most, result in the use of that version when the page is printed.

If you actually meant to ask how to force a background image, implemented with CSS, to be printed, then the answer is that you cannot. Just make it a content image. You could do that by dynamically changing, with JavaScript, the DOM so that before printing, a new img element is added to the DOM; but in normal circumstances, it is just so much simpler to include a static img element.

Upvotes: 2

Related Questions