Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

CSS supports media queries since Level 2, Revision 1. That's from way back in 2011, so any modern web browser should support it. If you're able to specify custom CSS, and apply custom CSS classes ...

posted 5y ago by Canina‭  ·  last activity 5y ago by System‭

Answer
#4: Attribution notice removed by user avatar System‭ · 2019-12-11T18:55:50Z (almost 5 years ago)
Source: https://writers.stackexchange.com/a/44452
License name: CC BY-SA 3.0
License URL: https://creativecommons.org/licenses/by-sa/3.0/
#3: Attribution notice added by user avatar System‭ · 2019-12-08T11:39:45Z (almost 5 years ago)
Source: https://writers.stackexchange.com/a/44452
License name: CC BY-SA 3.0
License URL: https://creativecommons.org/licenses/by-sa/3.0/
#2: Initial revision by (deleted user) · 2019-12-08T11:39:45Z (almost 5 years ago)
CSS supports [media queries](https://developer.mozilla.org/en-US/docs/Web/CSS/@media) since Level 2, Revision 1. That's from [way back in 2011](https://www.w3.org/TR/2011/REC-CSS2-20110607/), so any modern web browser should support it.

If you're able to specify custom CSS, and apply custom CSS classes to your content, then you can define a CSS class such that the pictures and other ancilliary content is shown on screen, but only the actual recipe is printed on paper.

This way, you don't need to have a separate "printer friendly" page, because you're using CSS to define what "printer friendly" means for your particular content. Of course, it assumes that you have control over the CSS in the first place! The person visiting your web site just prints via their browser's normal "print" function.

Specifically, as discussed [on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries), you can either target `print` media, or a specific characteristic of a media (a feature). For the former, you'd add something like

    @media print {
        img.food-photo { display: none; }
        body { color: black; }
    }

to hide `food-photo` class `img`s and set the text color to `black` when the rendering media is identified as `print`.

For the latter, you can target non-color-capable media (whether screen, print, or otherwise) by writing something like

    @media not color /* untested, but looks like it should work */ {
        body { color: black; }
    }

to set the text color to `black` where color is not supported.

These can be combined to form even more complex rules, and of course the normal CSS inheritance rules apply as well, so you can override only those attributes that need to be different between, say, print and non-print.

You might also be interested in CSS [feature queries](https://drafts.csswg.org/css-conditional-3/#at-supports), which look to be similar but geared toward even more specific feature support; for example, [one example](https://drafts.csswg.org/css-conditional-3/#typedef-supports-condition) shows how to apply specific CSS depending on whether `display: flex` is supported. This looks more useful for when you want to know that the user agent (browser) supports a feature, than for targetting specific media types or capabilities.

I came across a Stack Overflow question at [What does @media screen and (max-width: 1024px) mean in CSS?](https://stackoverflow.com/q/4189868/486504) which has some more complex examples that you may find enlightening.

I think that **the biggest downside** to using CSS for this is that it leaves the visitor with no easy way to print the whole page _including_ the "narrative/journey" if that's what they want to do. There are tricks that one can use, but those by their very nature _are_ rather technical.

#1: Imported from external source by user avatar System‭ · 2019-04-07T19:50:32Z (over 5 years ago)
Original score: 20