Adapting To The Ink: Tips And Tricks For Print Style Sheets

By Dudley Storey, Smashing Magazine FeedMarch 08, 2013 at 07:14AM


  

Print continues to be treated somewhat cursorily by most Web designers, who tend to be obsessed with pixels rather than printers. In the real world, a significant portion of people rely on pages printed from websites for reference: there’s still something about having a physical sheet of paper in one’s hands, even in this age of digital saturation.

Web developers can take several steps to bridge the gap between the worlds of printers and LCD screens:

  • Treat print as an equal partner in adaptive and responsive design.
  • Print background images and colors, where appropriate.
  • Add visible URLs or scannable links for easy reference from the printed page.
  • Use CSS filters to improve the result of printed graphics.

Design For Print, Not Screen

First, let’s cover the basics. Modern print style sheets are typically placed within a media query:

@media print {

}

Recreating the entire CSS for your website is not necessary because the default styles will, on the whole, be inherited by the print query; only the differences need to be defined. Most browsers will automatically reverse colors when printing in order to save toner, but this won’t have the same degree of quality as a handcrafted solution. For best results, make color changes explicit. At the very least, a basic print media query should consist of the following:

@media print {
   body {
      color: #000;
      background: #fff;
   }
}

While display: none has rightly been derided in responsive design, it is entirely appropriate for print style sheets: in most cases, our goal is not to recreate a screenshot of an entire page, but to provide a concise, well-designed print version of it. As a second step, eliminate page elements that are simply irrelevant in print, including navigation bars and background images.

/* Default styles */

h1 {
   color: #fff;
   background: url(banner.jpg);
}

@media print {
   h1 {
      color: #000;
      background: none;
   }

   nav, aside {
      display: none;
   }
}

Writing a print style sheet is one of the few times when you’ll ever use centimeters or inches in CSS. Largely irrelevant to screens, real-world measuring systems become very useful in print. To ensure that you are using the printed page effectively, write CSS to display your content edge to edge, negating any margins or padding that may be present, and balance this with an @page rule:

@media print {
   h1 {
      color: #000;
      background: none;
   }

   nav, aside {
      display: none;
   }

   body, article {
      width: 100%;
      margin: 0;
      padding: 0;
   }

   @page {
      margin: 2cm;
   }
}

For content to which users can be expected to add handwritten notes on the page, such as educational material, you might consider increasing the print margin.

We also need to ensure that content is not broken across pages when printed. One obvious step is to prevent headings from being printed at the bottom of the page:

h2, h3 {
   page-break-after: avoid;
}

Another rule will prevent images from bleeding over the edge of the printed page:

img {
   max-width: 100% !important;
}

A third will ensure that articles always start on a fresh page:

article {
   page-break-before: always;
}

Finally, we can prevent large elements, such as unordered lists and images, from being split across multiple pages.

ul, img {
   page-break-inside: avoid;
}

While these declarations are not exhaustive, they’re a good start.

Force Background Images And Colors

On some websites, such as portfolios, background images and colors are an important visual component. If the user is printing from a WebKit browser (Google’s Chrome or Apple’s Safari), we can force the printer to render the colors as seen on screen (i.e. force any background images and colors to appear on the printed page). Generally speaking, we would do this for color printers, which we can test for in a separate media query:

@media print and (color) {
   * {
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
   }
}

Sadly, there is (as yet) no immediate equivalent in Firefox, Opera or Internet Explorer.

Expand External Links For Print

We can’t (yet) directly interface with a printed page to explore links, so link URLs should be visible on the printed version of the Web page. To keep the page relatively clean, I prefer to expand only outbound links in articles, and suppress internal ones. If you’ve used relative URLs on your website for local links, you can easily do this through an attribute selector and :after pseudo=classes, thus preventing internal links and links around images from being printed:

@media print {
   article a {
      font-weight: bolder;
      text-decoration: none;
   }

   article a[href^=http]:after {
      content:" <" attr(href) "> ";
   }
}

Take the following HTML code and content:

<p>You’ve explored this <a href="/blog">website</a>; now it’s time to <a href="https://www.webplatform.org/">read other Web development documentation</a>.</p>

Here is the printed result:

Screen Shot 2013-01-13 at 8.58.10 PM

One issue is that anchor links and links around images will also be expanded on the printed page. We can fix the anchor links fairly readily with a countermanding CSS rule:

article a[href^="#"]:after {
   content: "";
}

Links around images are rather more difficult, because CSS does not currently allow for the selection of an element based on its children. Ideally, links around images would have a class that we could target via CSS. Longer term, CSS4 features a parent selector that will do the job:

$a:after > img {
   content: "";
}

CSS4 will also make expanding external links easier:

a:not(:local-link):after {
   content:" <" attr(href) "> ";
}

All of these approaches assume that users will continue to type in URLs by hand. A better solution is to make the digital version of the page easier to access by providing a matching QR code.

Print QR Codes For Easy URL References

Often regarded as an advertising eyesore, QR codes have their place in certain circumstances. One obvious example is providing an easily-scanned sigil on a printed Web page that enables the user to return to the live version without having to type the URL.

Web page printed with a self-referential QR code
Web page printed with a self-referential QR code. Larger view.

To create the matching QR code, we’ll use Google’s Chart API, which has four required components:

  • The kind of chart information we want Google to deliver (qr, in our case);
  • The rendered size of the QR sigil, in pixels;
  • The URL to encode;
  • The form of character encoding to use.

We’d typically associate the URL with a heading element at the top of the page:

<header>
<h1>Lizabeth’s Salon</h1>
<h2>Providing Intellectual Stimulation Online Since 2001</h1>
</header>

To create the printed result, we’ll provide a margin on the right side of the h1 that is large enough for the heading, and then position a QR code in that area:

header h1 {
   margin-right: 200px;
   margin-bottom: 2rem;
   line-height: 1.5;
}

Because the QR code will be unique to each page, this would be added as an embedded style sheet:

@media print {
   header h1:after {
      content: url(https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=https://yourdomain.com&choe=UTF-8);
      position: absolute;
      right: 0;
      top: 0;
   }
}

This approach has the downside of forcing the developer to enter a URL individually for each page into the API code. If your Web host is running PHP, you can provide the URL of the current page automatically:

@media print {
   h1:after {
      content: url(https://chart.googleapis.com/chart?cht=qr&chs=150x150
&chl=https://<?=$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>
&choe=UTF-8);
      position: absolute;
      right: 0;
      top: 0;
   }
}

For WordPress:

@media print {
   h1:after {
      content: url(https://chart.googleapis.com/chart?cht=qr&chs=150x150
&chl=https://<?phpthe_permalink();?>&choe=UTF-8);
      position: absolute;
      right: 0;
      top: 0;
   }
}

Obviously, both of the solutions above will only work on PHP and WordPress pages.

Use CSS3 Filters To Improve Print Quality

Browsers often have issues with printing out banner images, especially if the banners are white against a dark background:

Logo as a solid image Printed result
logo-black-background logo-black-background-printed
Logo as an alpha-masked PNG Printed result
logo-black-background logo-transperant-printed

In theory, you could use a CSS sprite to switch between different versions of the logo for print, but that would mean doubling the file size for potentially little benefit. Instead, I recommend using CSS filters (and their SVG equivalent, for Firefox) to invert the image just before it hits the printed page:

@media print {
   header {
      background: none;
      color: #000;
   }

   header img {
      filter: url(inverse.svg#negative);
      -webkit-filter: invert(100%);
      filter: invert(100%);
   }
}

CSS3 filters do what you’d expect — invert the colors in header images, turning black to white and vice versa — but they only work in Chrome and Safari. To cover Firefox, we need a different approach — the equivalent filter written as a separate SVG file:

<svg xmlns="https://www.w3.org/2000/svg">
<filter id="negative">
<feColorMatrix values="-1 0 0 0 1
0 -1 0 0 1
0 0 -1 0 1
0 0 0 1 0" />
</filter>
</svg>

The workings of the feColorMatrix SVG filter are a little complex to cover here. Much more information can be found in the article “Applying Color Tints to Web Pages With SVG Filters and JavaScript on Dev.Opera.

The result of printing either form of logo (i.e. alpha-masked PNG or solid-black background) is now this:

logo-inverted-printed

Conclusion

Due in part to the fact that printer use is not tracked by website analytics software and, thus, lacks strong metrics (although achieving this is possible, too, which we may discuss in a future article), print tends to be broadly ignored by Web developers. This is somewhat understandable, because most of the time we only read and browse pages online. As a result, developers tend to develop websites for the screens and devices in front of them, rather than for the printer at the other end of the office.

On the other hand, even if people only occasionally need to print something from the Web, it would be ideal if the page design adapted to the printer, just as modern websites adapt to various screen sizes and devices. Print should be considered another aspect of adaptive design, usability and accessibility, and an equally important part of Web development.

By treating print as another aspect of adaptive design, we fulfill the needs of more website users — and at the same time, save ink, paper and other resources, all of which are important aspects of sustainable design.

More Resources

A List Apart has a long and laudable history of supporting print style sheets through its articles and tutorials. While some of the following resources are now fairly old, they remain relevant to anyone who wishes to explore print as an equal partner in Web design.

Source of image on front page: Bottlerocket Creative.

(al)


© Dudley Storey for Smashing Magazine, 2013.

Universal Belay Device

By Kurt Sturm, University of Utah Technology Commercialization Office, iBridge Network InnovationsMarch 06, 2013 at 12:13AM

Invention
Summary

 

This is
the FIRST belay device that can be easily switched between a frictional mode and
auto-locking mode.  Switching
between the two modes can be done anytime without removing the ropes or
unclipping the device from the belayer’s harness. This means switching can occur
at any time without sacrificing safety. The universal belay device can also
handle single or double ropes of all commercially available diameters.  In frictional mode only a small force of
15-30 lbs is required to stop or “catch” a climber’s fall, while auto-locking
mode allows the device to be operated “hands-free” and immediately arrests a
climbers fall.  This technology is
available to license.

 

Features &
Benefits

 

·        
Switches between auto
locking and frictional modes without removing the rope or detaching from the
harness.

·        
Accommodates one or two
ropes.

·        
Use with
all rope diameters.

·        
The switch
can occur at any time.

·        
The device is safe for climbers making
the switch.

 

Market
Opportunity

 

Current
devices operate either in frictional mode or auto-locking mode. No device has
the capability to switch between the two options. This device can operate using
one or two ropes giving the climber options to choose
from.

 

The
Outdoor Industry Association (OIA) reports that over 9 million Americans
participated in recreational climbing last year. Military and search and rescue
teams are steady users and buyers of climbing and rappelling
equipment.

 

Intellectual Property

 

Two US
patents (No. 7,757,812, 8,316,989) has been issued from the US Patent and
Trademark Office.

 

Inventors

 

Dr. Eberhard Bamberg,
Ph.D., Dept. of Mechanical Engineering, University of Utah

 

Nathanial Young,
Department of Mechanical Engineering, University of Utah

 

This new technology
is available on an exclusive or nonexclusive basis.

 

 

Supercharge Your Pocket Experience With These IFTTT Recipes

By Nancy Messieh, MakeUseOfMarch 05, 2013 at 10:31PM

ifttt recipesBetween the two of them, Pocket and IFTTT are excellent services that do their part in making their users more productive. Pocket gives users a one-stop shop to access all of the content – articles, videos and more – that they want to save for later viewing.

Combine that with IFTTT, the ultimate automating service, and you have the ultimate way to automatically save content to your Pocket account, easy ways to share that content with others, and no limits to the kinds of content you can save to Pocket. IFTTT can also be used to keep up with new freebies, to automate your online interactions, and much more. With both of them extremely versatile tools, you can come up with a variety of interesting recipes that put Pocket to proper use. We’ve listed a few of our favourite recipes that we think will supercharge your Pocket use.

If you’re still getting the hang of IFTTT, be sure to check out our guide here.

Automatically Tweet Your Pocket Favourites

As your working your way through your Pocket reading list, if you want to get a certain flow going as you work, there’s one way you can tweet out interesting articles as you finish them without interrupting that workflow. Rather than manually tweet out the articles that you want to share with your Twitter followers, with this ifttt recipe, you can automatically tweet any articles you mark as your favourites in Pocket.

ifttt recipes

While Pocket does provide an easy tweet button to access, this method is far more fluid and will probably let you get through more articles in a shorter amount of time.

Save Pocket Favourites To Your Tumblr Blog

Let’s say you want to recommend your Pocket favourites to more than just your Twitter followers? If you want a page that’s all your own – filled only with recommended links for people to read – you could always send your Pocket favourites to a Tumblr blog using this recipe.

ifttt recipe ideas

When adding a story to your favourites, Tumblr is one of the best automated options since you can choose to create a link post. Your Tumblr blog could then become a unique recommended reads site accessible to anyone who has the link.

The recipe, as is, shares the title and link, but you could also choose to add an excerpt if you want.

Send links From Your Twitter Favourites To Pocket

While Twitter pulled the plug on its IFTTT integration, there are still some workarounds that people have come up with that allow you to still take advantage of that connection. This recipe sends links in your Twitter favourites to your Pocket account.

To use this recipe, all you have to do is paste the following in the RSS field, replacing ‘username’ with your Twitter username:

“https://api.twitter.com/1/favorites/username.rss”

ifttt recipe ideas

Save New Posts From A Site To Pocket

If there’s a specific site you know you don’t want to miss out on any of their posts, you can create a site-specific recipe that will be triggered each time its RSS feed is updated. We’ve created a recipe that does just that for the MakeUseOf site – so that all articles from the blog will end up in your reading queue.

You can replace the MakeUseOf RSS feed with any site of your choice, but we’d certainly encourage you to include MakeUseOf in your Pocket reads!

ifttt recipe ideas

Save Videos To Watch On Pocket

While Pocket is all about saving articles to read for later, there’s no reason you can’t use it for a bit of light entertainment as well. With these two recipes – one for Vimeo and one for YouTube – you can save videos to watch later by sending them to Pocket. Both recipes use the same triggers – simply mark the videos on the video sharing site to watch later – and they’ll automatically end up in your Pocket queue.

ifttt recipes

The cool thing about using these kinds of recipes is that you can create a playlist of sorts for yourself from both YouTube and Vimeo, and watch them all in one place.

Send Pocket Items To Your Kindle

If you want to save Pocket articles to your Kindle, you can use this recipe which takes advantage of the Kindle-Instapaper connection. This recipe works by sending your archived (or marked read) Pocket items to your Instapaper account. In order for the article to make it all the way onto your Kindle, you have to have the Kindle-Instapaper connection set up. You can do this by going to the Kindle page in your Instapaper account.

What are your favourite Pocket-related IFTTT recipes? Share them with us in the comments.

The post Supercharge Your Pocket Experience With These IFTTT Recipes appeared first on MakeUseOf.