Forcing Grayscale Printing

At the time of this writing, this will only work in Chrome 18+, but it's standardized so support will eventually come to everywhere.

@media print {
  body {
    /* IE4-8 and 9 (deprecated). */
    filter: Gray();
    /* SVG version for IE10, Chrome 17, FF3.5, 
       Safari 5.2 and Opera 11.6 */
    filter: url('#grayscale'); 
    /* CSS3 filter, at the moment Webkit only. Prefix it for
       future implementations */
    -webkit-filter: grayscale(100%); 
    filter: grayscale(100%); /* future-proof */
  }
}

Reference URL

Comments

  1. User Avatar
    Xavi
    Permalink to comment#

    I was trying to use this code in my blog social icons but it’s not working well:

    Chrome – great result, the icon appears in grayscale
    IE – the icon appears with color
    Firefox – the icon doesn’t appear at all

    I think it’s this line that doesn’t work:

    filter: url('#grayscale'); 

    I have the svg filter when the body tag opens as defined in the referenced url.

    Any idea how to solve it?

  2. User Avatar
    Arul
    Permalink to comment#

    for me its not working for IE10 how to make it for IE10

  3. User Avatar
    Rooba
    Permalink to comment#

    Not working for ie 10

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

Submit a Comment

icon-closeicon-emailicon-linkicon-menuicon-searchicon-tag