Making Your Site Printable Presented by Adrian Roselli July 15, 2014 #CSSSummit.

Slides:



Advertisements
Similar presentations
Coding a Responsive HTML
Advertisements

HTML Basics Customizing your site using the basics of HTML.
Iframes & Images Using HTML.
Cascading Style Sheets
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Web Standards XHTML and CSS. Today’s Show ► Discuss web standards ► XHTML ► Layout Without Tables ► CSS ► Why Web Standards?
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Chapter 8 Creating Style Sheets.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Creating Special Effects with CSS
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 4 Creating Special Effects with CSS
Chapter 4 Adding Images. Inserting and Aligning Images Using CSS When you choose graphics to add to a web page, it’s important to use graphic files in.
4.01 Cascading Style Sheets
TUTORIAL 8: Enhancing a Web Site with Advanced CSS
Lesson 15: Mobile Design and Layout Introduction to Adobe Dreamweaver CS6 Adobe Certified Associate: Web Communication using Adobe Dreamweaver CS6.
WDV 331 Dreamweaver Applications Designing Websites for Mobile Devices Dreamweaver CS6 Chapter 11.
CIT 256 Organizing Large Websites: Divs, DW Templates Dr. Beryl Hoffman.
Online Chapter 1 4 th Edition.  Review elements  Whitespace handling  Rule structure  Linking to an external style sheet  Alternate Style Sheets.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Using Styles and Style Sheets for Design
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
Basic Responsive Design Techniques. Let’s take a look at this basic layout. It has a header and two columns of text, in a box that is centered on the.
Chapter 2 Developing a Web Page. Chapter 2 Lessons Introduction 1.Create head content and set page properties 2.Create, import, and format text 3.Add.
Week 8 – Part 3 More on Links, Layout, and Mobile Key Concepts 1.
IDs versus Classes Naming Your Tags for Maximum Functionality.
XP Dreamweaver 8.0 Tutorial 3 1 Adding Text and Formatting Text with CSS Styles.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Programming in HTML.  Programming Language  Used to design/create web pages  Hyper Text Markup Language  Markup Language  Series of Markup tags 
Copyright 2012 Adobe Systems Incorporated. All rights reserved. ® Copyright 2010 Adobe Systems Incorporated. All rights reserved. ® Copyright 2012 Adobe.
Style Sheets for Print and Mobile Media Types Supplemental Material.
XP New Perspectives on Microsoft Word 2002 Tutorial 31 Microsoft Word 2002 Tutorial 3 – Creating a Multiple-Page Report.
Tutorial 8 Enhancing a Web Site with Advanced CSS
Adobe Dreamweaver CS3 Revealed CHAPTER THREE: WORKING WITH TEXT AND IMAGES.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 7 Key Concepts 1 Copyright © Terry Felke-Morris.
HTML, CSS, and XML Tutorial 8 Enhancing a Web Site with Advanced CSS.
Tutorial #6 – Creating Fixed Width Layouts. Tutorial #5 Review – Box Model Every html element is surround by a box Content, Padding, Border, Margin Can.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Principles of Web Design 6 th Edition Chapter 9 – Site Navigation.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 8: Working with Style Sheets.
Tutorial 3 Adding and Formatting Text with CSS Styles.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 7 Key Concepts 1 Copyright © Terry Felke-Morris.
Positioning and Printing Creating Special Effects with CSS.
Advanced Topics Lecture 8 Rachel A Ober
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Cascading Style Sheets Primary readings Presentations Explain & review projects with class mates.
Positioning Objects with CSS and Tables
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
© 2004 The McGraw-Hill Companies, Inc. All rights reserved. The Advantage Series Microsoft Office Word 2003 CHAPTER 4 Printing and Web Publishing.
Working with Cascading Style Sheets
Implementing Responsive Design UNIT I.
Weebly Elements, Continued
Implementing Responsive Design
Microsoft Office 2007-Illustrated
Styling For Print From Screen to Paper
CS 321: Human-Computer Interaction Design
OverDrive Digital Library Basics
Objectives Create a media query Work with the browser viewport
OverDrive Digital Library Basics
How to customize your Microsoft SharePoint Online website
Tutorial 3 – Creating a Multiple-Page Report
Session IV Chapter 15 - How Work with Fonts and Printing
Welcome To Microsoft Word 2016
Presentation transcript:

Making Your Site Printable Presented by Adrian Roselli July 15, 2014 #CSSSummit

About Adrian Roselli Co-written four books. Technical editor for two books. Written over fifty articles, most recently for.net Magazine and Web Standards Sherpa. Great bedtime reading!

About Adrian Roselli Member of W3C HTML Working Group, W3C Accessibility Task Force, five W3C Community Groups. Building for the web since Founder, owner at Algonquin Studios (AlgonquinStudios.com).AlgonquinStudios.com Learn more at AdrianRoselli.com.AdrianRoselli.com Avoid on Twitter I warned you.

What We’ll Cover

Background Techniques Measuring Future Questions

Background

Responsive Web Design (RWD) Responsive design (or adaptive design) is about supporting any device: Desktop computer Smartphone Tablet Television Printer? Photo of printed page from

PrintShame.com As developers tout their responsive designs, they often forget the printed page. Support for print styles goes back more than a decade, before RWD. Used MediaQueri.es as initial seed, then picked up from articles, awards, etc. Hoped shaming might improve state of print styles.

PrintShame.com

PrintShame.com Source page:

Maturing (a bit) Decided the best approach would be teaching. Used lessons, common issues from PrintShame to develop tutorial(s). Pitched this very talk.

Print Services Add a third-party “print” button to your site. You have no control over layout. You have no control over ads. You have no control.

Print Services “More Evidence of the Need for Print Styles”

Techniques

Screen versus Print Screen Continuous Visual, audible, tactile Vector and bitmap Interactive Online Print Paged Visual Bitmap Static Offline

Planning Is my site built mobile-first? Things I want the user to see. Things the user may not want to see. Things that probably won’t print anyway.

Planning Is my site built mobile-first? Sometimes your mobile-first styles will get you nearly all the way there. If you built desktop-first, you may be able to re- use your smaller viewport styles.

Planning Things I want the user to see: Branding Cross-branding Page address Copyright Path to page (breadcrumb) Link addresses (?)

Planning Things the user may not want to see: Primary navigation Secondary navigation Site search Social media icons Ad banners Fat footers

Planning Things that probably won’t print anyway: Colors Backgrounds (images and colors) Bits of timed / interactive elements White elements (logos, text, effects)

Examples: Caveats The following CSS examples are just examples. Selectors vary between IDs, classes and elements to show something that may be familiar to everyone Styles may differ from what is on the live site, sometimes to remove redundancy or simplify code samples.

Example

No Print Styles

Calling Print Styles Make a home for your print print { /* insert your style declarations here */ } Or:

General Styles Reset type sizes to points, set text to black. Points (mostly) provide more consistent text size across browsers and devices than pixels. Light grey text doesn’t trigger browser overrides to convert text to black. Not all users have color printers. Set red to black so it doesn’t come out as a medium gray (perhaps with other styles as appropriate).

General Styles Clear whitespace around the content. User’s print settings will handle page margins. Lets user get as much content on a page as possible (yay for trees!). You shouldn’t need to worry about portrait vs. landscape, A4 vs. 8.5×11, etc.

General Styles Write values of title (or alt, or data- *, etc.) attributes into the page. on blockquote, on abbr. You can do this with most attributes on most elements, although it might not be a good fit. Perhaps attribute to display a minified link address to make it easier for users to type URLs. A novel way to

In-Page Links Select links in content container(s) and then display the href value as text after the link. #Content a[href]:after { content: " [" attr(href) "] "; word-wrap: break-word; } #Content a[href^="#"]:after, #Content a[href^="tel"]:after, #Content a[href^="mailto"]:after, #Content a[href^="javascript"]:after { content: ""; } Yes, you can do the inverse selector, but then I don’t get to show the variations!

First Round of Changes

Navigation Get rid of the primary, secondary, tertiary navigation, Remove social media links, Remove other bits that won’t make sense when printed. #Nav, #FlyOutNav, #SubNav,.NoPrint, #SMLinks { display: none; }

Navigation

Breadcrumb Keep the breadcrumb as a wayfinding method, but reduce its size and don’t expand the links. #Bread a:link, #Bread a:visited { text-decoration: underline; color: #000; } #Bread { color: #000; font-size: 6pt; } #Bread > a:after { content: ""; }

Banner Change any text to print units, Adjust colors, Handle spacing, Make sure you keep the logo. Consider SVG.

Footer Change any text to print units, Adjust colors, Handle spacing, Remove unneeded bits. footer { border-top: 1px solid #000; font-size: 6pt; color: #000; background-color: transparent; } footer p { margin: 0; color: #000; } footer p a::after { content: attr(data-alt); } footer img { display: none; }

Page Breaks The CSS properties page-break-before, page- break-after and page-break-inside have the following values: auto : default value, no specified behavior. avoid : tries to avoid a page-break. always : invokes a page-break (not for page-break- inside ). left | right : Tries to place element on the start of a page on the left or right, for when you are printing bound material (books, magazines, etc.) (not for page-break-inside ).

Further Consideration Hide videos. Hide controls for embedded audio. Hide Flash movies. Hide canvas elements (assuming interactive). Don’t scale images to 100% width (looking at you, mobile styles and frameworks). Determine if ads should be printed or not.

Before (9 pages)

After (2 pages)

Widows and Orphans Use these to control how many lines must be at the end of a page ( orphans ) or how many at the start of a page ( widows ). p { orphans: 3; /* 3 consecutive lines at end of page */ widows: 2; /* 2 lines at start of new page */ } Because widows and orphans are confusing:

Invert Logos For those rare cases with a white logo where you can’t load an alternate image (Chrome & Safari only): Img#Logo { -webkit-filter: invert(100%); filter: invert(100%); } If you can load an alternate, a quick tutorial:

QR Codes They’re a personal (lifestyle) choice. Allows more savvy users to get directly to the source of the printed page. Easy to implement without burdening mobile users, users who do not print. Not perfect – they don’t always fire in time.

Call the QR print { header::before { content: url( chl=http%3A%2F%2Falgonquinstudios.com/Engage/Careers); } }

QR Code in Use

Mobile Consider the explosion of mobile. Same goals on mobile as desktop. Mobile has played catch-up in print, but has arrived within past year. Firefox & Safari print background colors. Firefox used odd page size. Android browser outputs raster PDF. Printing from Mobile Has Improved:

Mobile Android BrowserChromeFirefox

Mobile Android BrowserChromeFirefox

TEST! Print to PDF for your first (most) rounds. Chrome Developer Tools (next slide). Use every browser you can. Use each browser visiting your site. Change paper size (8.5" × 11", A4, etc.). Change paper orientation. Scale the content in the print dialog.

Chrome Developer Tools 1.Open the drawer, 2.Select the Emulation tab, 3.Choose Screen, 4.At the bottom check CSS Media, 5.Choose print from the menu.

Chrome Developer Tools

Measuring

Google Analytics Call the GA tracking image, but only when the print styles get used. Attach a custom event to that image. View custom events in Google Analytics. Identify which pages get printed. Make sure that at least those pages print well. For fun, compare to your carousel. Full tutorial:

Query String Parameters VariableDescription utmac Account String. Appears on all requests. This is your UA-#######-# ID. utmwv Tracking code version. While my standard GA requests use 5.4.0, I opted to use 4.3 for reasons I no longer recall. utmn Unique ID generated for each GIF request to prevent caching of the GIF image. I just concatenate the current year, month, day, hour, minute and second. utmhn Host Name of your site, which is a URL-encoded string. utmr Referral, complete URL. In this case I just insert a dash so it is not blank. utmp Page request of the current page. utmt Indicates the type of request, which is one of: event, transaction, item, or a custom variable. If you leave it blank, it defaults to page. Because I am tracking events, I use event. utme Extensible parameter. This is where you write your event. I use 5(Print*{page address}). utmcc Cookie values. This request parameter sends all the cookies requested from the page. It can get pretty long. It must be URL encoded. It must include __utma and __utmz values.

Sample Query String ?utmac=UA &utmwv=4.3 &utmn= &utmhn=algonquinstudios.com &utmr=- &utmp=/Engage/Careers &utmt=event &utme=5%28Print*/Engage/Careers%29 &utmcc=__utma%3D %3B%2B__utmb%3D %3 B%2B__utmz%3D utmcsr%3D%28direct%2 9|utmccn%3D%28direct%29|utmcmd%3D%28none%29

Call the print { header::after { content: url( analytics.com/__utm.gif?utmac=UA &utmwv=4.3&utmn= &utmhn=algonquinstudios.com& utmr=&utmp=/Engage/Careers&utmt=event&utme=5%28Print*/Enga ge/Careers%29&utmcc=__utma%3D %3B%2B__utmb%3D %3B%2B__utmz%3D utmcsr% 3D%28direct%29|utmccn%3D%28direct%29|utmcmd%3D%28none%29); }

Check the Data

Future

Here or on Its Way Browser support for existing features. Electronic Books. HTML5 as a publishing platform. CSS3, CSS4.

Page Rules rule allows you to specify page margins (CSS 2.1), size and orientation { margin: 20cm; size: A4 landscape; } I recommend you do not use it and defer to user preferences.

Left, Right, First Pages rule with pseudo classes to specify right, left, first: :right will affect the page on the right. :left will affect the page on the left. :first will affect the first page. :blank will affect the blank pages resulting from forced break. rule with no pseudo classes applies to all pages.

Bleed and Crops The bleed property relies on the crops property having a value. Bleed specifies how much the page can extend outside the page box: units, referring to width of page box. Crop draws marks outside page box: crop : shows where a page should be cut. cross : used to align sheets.

Boxes across Pages The box-decoration-break specifies how a box’s background, margin and border behave when broken across pages: slice : chops the box in two. clone : duplicates the styles onto each box.

Page Margin { content: "Copyright me." { counter-increment: page; content: "Page " counter(page); }

Wrap-up, Questions

Further Reading Tracking Printed Pages (or How to Validate Assumptions) webstandardssherpa.com/reviews/tracking-printed-pages/ webstandardssherpa.com/reviews/tracking-printed-pages/ Make your website printable with CSS: Calling QR in Print CSS Only When Needed: rosel.li/ rosel.li/ Tracking When Users Print Pages: rosel.li/ rosel.li/ Tips And Tricks For Print Style Sheets: coding.smashingmagazine.com/2013/03/08/tips-tricks-print-style-sheets/ coding.smashingmagazine.com/2013/03/08/tips-tricks-print-style-sheets/ Printing The Web: drublic.de/blog/printing-the-web/ drublic.de/blog/printing-the-web/ CSS Paged Media Level 2: CSS Paged Media Module Level 3: Proposals for the future of CSS Paged Media: dev.w3.org/csswg/css-page-4/ dev.w3.org/csswg/css-page-4/ Can you typeset a book with CSS?

Making Your Site Printable Presented by Adrian Roselli July 15, 2014 #CSSSummit