Top Banner
Slightly Improving HTML Email With CSS Media Queries Steve Noone – 4/17/2013
20

Responsive HTML Email for iOS

Jul 31, 2015

Download

Documents

Steve Noone
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Responsive HTML Email for iOS

Slightly Improving HTML EmailWith CSS Media Queries

Steve Noone – 4/17/2013

Page 2: Responsive HTML Email for iOS

What are CSS Media Queries?Style rules scoped to specific device attributes

Options Include:

Min/max-device-width: ???px

Min/max-device-pixel-ratio:

Orientation: portrait/landscape

Min/max-width (viewport size): ???px

Page 3: Responsive HTML Email for iOS

CSS3 Media Queries:Support added in FF3.5, Chrome 4, IE9*

@media all and (max-device-width: 480px) {

/* Styles for views not wider than 480px */

}

<link rel='stylesheet' media='screen and (min-width: 340px) and

(max-width: 640px)' href='css/medium.css' />

*Current versions are FF v21, Chrome v26, IE v10

Page 4: Responsive HTML Email for iOS

Your phone is lying to you

Page 5: Responsive HTML Email for iOS

Your phone is lying to you (by design, per the CSS 2.1 specification)

CSS pixels now have nothing to do with the actual pixel density of the device. They’re an abstract construct created specifically for web developers.

It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm's length.

Page 6: Responsive HTML Email for iOS

A pixel is not a pixel:Hi-dpi displays double or triple px values

Page 7: Responsive HTML Email for iOS

CSS Media Queries:Hi-dpi phone displays double or triple px values

@media all and (-webkit-min-device-pixel-ratio: 1.0) {

/* Old iOS, OG Samsung Galaxy, etc */ }

@media all and (-webkit-min-device-pixel-ratio: 2.0) {

/* iPhone 4/5, iPad, Nexus 4, Note II, MacBook Pro */ }

@media all and (-webkit-min-device-pixel-ratio: 3.0) {

/* 1080 Smartphones (HTC One, GS4, Maxx HD */ }

Page 8: Responsive HTML Email for iOS

Goals for Mobile Email UX

Avoid horizontal scrolling

Good readability without requiring zoom

Bandwidth-friendly (images optional)

Touch-friendly (large click areas)

Broad compatibility (iOS, Android, Windows, etc)

Page 9: Responsive HTML Email for iOS

Phone-optimized CSS

Page 10: Responsive HTML Email for iOS

What’s Missing in HTML email?

Pixel-perfect predictability

Standards for resolution (1080 may be it)

Font availability (also no web fonts)

External/linked CSS stylesheets

Javascript

Page 11: Responsive HTML Email for iOS

The Outlook Problem

Page 12: Responsive HTML Email for iOS
Page 13: Responsive HTML Email for iOS

Why So Serious?

Outlook uses the MS Word HTML rendering engine

Only TABLE layouts are reliable

Only inline CSS on SPAN tags is reliable for style

Enforced default styling for many tags (H1, P, etc)

Display: none is broken/unreliable

Page 14: Responsive HTML Email for iOS

Google is broken, too.

Page 15: Responsive HTML Email for iOS

No Gmail support for:

CSS3 Media Queries

Linked CSS or embedded STYLE tags

Many CSS selectors

Basic CSS (margin, border, floats)

Display: none is broken/unreliable

Page 16: Responsive HTML Email for iOS
Page 17: Responsive HTML Email for iOS
Page 18: Responsive HTML Email for iOS

Email Open Rates (Early 2012)

Page 19: Responsive HTML Email for iOS

Progressive Enhancement

Build & test email in Outlook & Gmail

Use TABLES & INLINE STYLES on SPAN tags

Use % widths, not pixels for nested tables

More text/fewer images

Use Media Queries to target iOS and Android Mail

Page 20: Responsive HTML Email for iOS

Things we can control

Reliably hide elements on iOS

Increase font sizes to eliminate zooming

Change parent table from fixed to % width

Override inline styles with !important

Use Media Queries to target iOS and Android Mail