8

Is possible to print a background-image whithout enabling "Print Background colors and images" in Advanced tab of Internet Options ?

I think to use a alternative way without "background-image"... Using div tag and position absolute is possible to emulate the same effect of background-image? Also I would like to repeat the background image through the page.

Douglas V. Pasqua
  • 163
  • 1
  • 4
  • 10

1 Answers1

4

The ability to print background images (those images specified as background-images in the markup) is entirely up to the end user, you can not control this programmatically from your code. There is a plugin for Firefox that provides a JavaScript API to control many print settings - this might be able to control background-images. However, this obviously only works in Firefox and is dependent on the end user having this particular plugin installed.

You could use absolutely positioned IMG tags and manage the z-index of layered containers to push the IMG to the back, but TBH it's starting to get messy and you may not be able to achieve the affect you are after and maintain correct semantic markup. Certainly if you want the IMG to repeat you'd have to resort to JavaScript to create and position multiple IMG tags, or create one large image that you have manually tiled - not recommended.

Unless you have a specific requirement, users generally do not want (or need) background images to be printed - hence the easy reach option in the browser. So it may be best to rethink the problem. Print and screen are two very different media so you shouldn't necessarily try to mimic on screen display in print, hence CSS's ability to create print only stylesheets - if that is what you are trying to achieve?

MrWhite
  • 43,179
  • 8
  • 60
  • 84
  • 1
    I often you use `background-image` as an alternative to `img` because it simplifies HTML (just one `` tag instead of ``) and because it allows me to easily center/crop the image in the target element - something which would be insanely difficult to achieve with `` tags, most likely requiring the use of a `` to achieve vertical centering (and I've no idea about cropping).
    – Vilx- Nov 17 '11 at 11:38
  • 1
    @Vilx- I would agree, but a `background-image` isn't necessarily an _alternative_ to the `img` element. `img` is part of the document content and therefore might require alternative content in order to be accessible, whereas a `background-image` is just visual gloss to make it look good, which is probably all that's required for the background of an anchor, providing it already has 'content'. – MrWhite Nov 18 '11 at 15:14