Responsive Design Best Practices PDF
Responsive Design Best Practices PDF
Best Practices
Advice, Tutorials, Case Studies
Copyright © 2015 by UXPin Inc.
Responsive Navigation 44
Touch Targets 45
Feedback 47
Consistency 48
Clarity 50
Useful Navigation Patterns 54
Additional Examples 62
Tutorial: Responsive Navigation Drawer 66
How to add “a come back” 72
How to show the navigation drawer on swipe to the
left and hide it on swipe to the right 74
How to make “left-side” navigation drawer 75
Responsive Typography 78
Reading Distance 79
Establishing Responsive Text Size 81
Line Height 84
Line Length (Measure) 86
Conclusion87
Responsive Images 88
Choosing the Right Format for the Job 89
Squeezing Every Byte 93
Compression Services 93
Code Considerations 99
Implications for UI Design 101
Responsive Web Design, or RWD for short, is an oft talked about and
frankly invaluable discipline in the context of today’s design industry.
Moreover, it’s a term that grows more robust in meaning as different
ideas and aspects of device usage are introduced to the public. A few
short years ago, it was enough for a design to render attractively in
four or five different preset viewports.
And while there were once multiple options for serving mobile users,
such as m-dot sites or heavy reliance on mobile applications, the
most relevant research to date shows that these solutions just aren’t
as consistent or as cost effective as a responsive design.
In this book, we’ll guide you through the ins and outs of making your
work not just respond well to different screens, but a delight to use
across a range of browsing experiences. Beginning broadly with RWD
as a concept, we’ll work our way through to specific examples of how
and why to use certain methods to achieve the most attractive and
consistent design regardless of the user’s device.
By the time you’ve finished reading, you should have a solid under-
standing of what RWD is, when, where, why, and how you should
apply specific techniques according to the needs of a certain situation.
No matter what your level of familiarity with RWD right now, you
will be able to glean additional insights by delving deeper into the
topics and techniques described within this book.
3. Media queries – A CSS3 module that controls how the styles with-
in the media attribute are applied. Different styles are applied
according to a number of device specific qualities such as screen
width, height, orientation, etc.
• Truly future-proof since you don’t need to obsess over every new
device screen size
• Pure Oxygen Labs reports that last year M-dot sites fell 20%,
from 79% in 2013 to 59% in 2014, while responsive and adaptive
(dynamic serving) sites rose 37% collectively.
• Users visit the full site anyway – Web Performance Today’s re-
search showed that about a third (35%) of users choose to go to
the full site if given the option.
• Users spend more time on the full site – The same research
states 5.5 times longer. They also calculated that 79% of revenue
from mobile sales came from users on the full site.
Understanding the Case for Responsive Web Design 14
• Redirect time – While M-dot sites load faster in theory, the extra
time of redirecting from your full site to the M-dot (unless the
user types the M-dot’s URL) is unnecessary. Alongside the other
drawbacks, is it worth it?
• Mobile devices aren’t a single screen size – It’s ironic that what
was once the greatest strength of M-dot sites is now its greatest
weakness. M-dot sites are designed for a specific screen size, but
mobile devices range from 320×240 for some smartphones up to
768×1024 (and beyond) for tablets. It just doesn’t make sense to
serve the same layout to all those screens.
Bottom line: M-dot sites are a bad idea because they cost more and
create inconsistent experiences.
There are numerous examples of sites who make the switch to RWD
being exponentially more successful after a relaunch. Let’s take a
look at an example from a case study performed by Google on the
British Internet Service Provider, Plusnet.
Understanding the Case for Responsive Web Design 15
Takeaway
More people are using mobile now than ever before, and the number
of mobile users is continuing to grow. More than half of the popu-
lation has a mobile internet service subscription, and by the end of
2020, that number is projected to grow by another billion people.
Understanding the Case for Responsive Web Design 17
But, as we’ve discussed so far, simple media queries, fluid grids, and
flexible images aren’t enough to provide the best possible UX. What’s
required of designers now and in the future will be an open mind
and a flexible attitude to match that of the evolving web.
That’s what your philosophical aim is, and so that’s what you have
to bring to your practical applications. An idea of fluidity and an
attitude well-suited to the embrace of inevitable change.
You can’t anticipate the conditions in which users view your work.
It seems like the entire design industry reinvents itself every 5 years
or so already.
Consider:
A truly responsive design is one that truly takes all of this into account,
and builds allowances for future developments into the infrastruc-
ture. This can get confusing in a hurry.
Mastering the Responsive Design Philosophy 20
How are you supposed to make allowances for something that you
can’t predict? The secret is to be open-ended in your expectations
and to find creative workarounds when confronted with constraints
you’d normally think of as immutable.
To elaborate, that means you must endow your designs with fluidity,
inside and out. Which includes all of the following:
One thing that will help you accomplish this in reference to typog-
raphy is the use of ems or rems.
• Ems are the relative units of measure which can be used to change
the size of typography in relation to the element in which it’s con-
tained.
• Rems on the other hand are similar, but they conform to the size
of the Root element, as in the top level of HTML, instead of the
element containing the typeface.
When coding in fixed pixel sizes, you’ll find your layouts will be re-
strictive and they won’t scale very well across a wide range of plat-
forms. But implementing ems or rems means you’ll always have a
text size that renders at a constant proportion to screen size, or more
specifically, the size of the block of content in which it’s contained.
You need more than just your typeface to scale up or down attractively.
That’s where SVGs (or Scalable Vector Graphics) come in. These
are images that aren’t composed of pixels, but rather made of paths.
that as screen resolution increases, the image doesn’t lose any quality
because it’s still being rendered along the same paths. Zoom in or out
on an SVG as much as you like and you still get the same image with-
out all the blocky pixelated artifacts you’d get from a raster image.
• Layouts benefit from relative units. Fixed pixel sizes restrict lay-
outs to certain devices.
Now that we’ve covered some characteristics that match the respon-
sive philosophical bent, it’s time to move on to the real star of your
designs: the user.
Mastering the Responsive Design Philosophy 23
You’ve heard that content is king and you must design for mobile
devices first. Both the mobile-first and content-first approaches are
fine. They’re helpful ways to frame your thinking. It’s always easier
to scale up than it is to scale down. However, neither are very useful
without a purpose-first approach.
Mastering the Responsive Design Philosophy 24
Without a clear purpose in mind, mobile and content are, well, mean-
ingless.
What gives design its purpose? Certainly there are business objectives
that must be achieved, but sales are only possible when a business’
goals are aligned with those of the user.
• Buy a product.
• Sign up for a newsletter.
• Donate to a cause.
• Agree to or accept a certain point of view (as is the case with po-
litical campaigns, for example).
• What will the business do with collected emails, and what useful
information will the end user get in return?
Answering questions like these will help prioritize what the design
conveys at any given screen size.
Mastering the Responsive Design Philosophy 25
For every page you put together, think about each element and
whether it would matter to the user if it disappeared. If you conclude
that users won’t miss an element, then you’re better off discarding
it. The less elements on the screen, the better (and faster) the layout
adapts to devices.
Here are a few examples of functions that require you to think be-
yond screen:
Even though it’s nice to add elements that provide value, you still
only want the minimum amount of elements per page.. This can be
tricky. You need a system to decide whether or not a design needs
one element or another.
3. Start by laying out the content for the smallest viewport, then
expand your layout for larger views. Create a minimum of 3
Mastering the Responsive Design Philosophy 27
To clarify on that first item, taglines are extremely helpful when de-
termining the importance of on-page elements, features or functions.
For example:
• “Financial advice that takes the pain out of paying bills.”– Min-
imalism is a must here. People want to find the info they want as
quickly as possible and get out of the site. For the smallest viewport,
present only a single clear log-in option above the scroll.
• “The go-to source for all things digital design...”– This is clearly
a text heavy service. You’ll need to lay out blocks of text in a flow-
ing, easy-to-scroll manner. In this case, consider the mostly fluid
layout to fulfill your purpose.
• Avoid stock art unless it tells a story. Lean towards art that only
works with the material at hand. If it could work with anything
Mastering the Responsive Design Philosophy 30
else on the site – say, any of your blog posts – then it’s too generic
to be meaningful.
Part of this is leveraging what data you can gather, which these days
is quite a lot. Be sure that your interfaces take into account the any
previously logged data, such as:
• Search settings.
• Search history.
• Preferred location.
• Previous purchases.
Remember too though, as many marketers will tell you, it’s easy to get
bogged down with the details when dealing with large datasets. The
more important consideration you can make is to let users control
their browsing experience. They know better than you what’s going
on in their individual case. So make sure they can:
Now that you’ve got a good idea of the specific attributes of a success-
ful responsive design, let’s examine a real world application.
Mastering the Responsive Design Philosophy 34
Smallest Viewport:
Largest Viewport:
Mastering the Responsive Design Philosophy 35
Virgin America has a trendy reputation already, and this case study by
Work & Co represents yet another step in the direction of responsive
design savviness. Note how the home page puts the user’s content
needs front and center across multiple viewports.
• The drop down items (Guests, From, To) aren’t only available on
the largest viewport (desktop). In the smallest viewport (smart-
phone), the items are instead presented in a new window. The
core task is unaffected by device.
Smallest Viewport:
Mastering the Responsive Design Philosophy 36
Once you decide upon your departure and arrival dates, the inter-
face even provides a fantastic bit of conversational feedback “[Date],
looks good.” at the top of the page:
Smallest Viewport:
The user is in the driver’s seat from the first step of the booking pro-
cess all the way through. The navigation is simple, straightforward,
intuitive, and familiar across devices. What’s more, when in the
smartphone view, the primary content immediately fill their view-
ports with a single touch.
• Cool subdued color schemes – Puts the user at ease while working
through the often stressful process of planning for travel.
Conclusion
This means making allowances and changes for the ways that cer-
tain users in specified locations will be likely to interact through
geolocation, remembering their preferences, examining their search
histories and other data related matters.
But more than that, it means allowing the user to take control of their
interactions. Let them determine their direction and engagement. Your
design should simply be there to guide them toward their own goals.
5 Useful Responsive
Design Layouts
1. Mostly fluid
Luke’s “mostly fluid” pattern reflows content dynamically within
a fixed parent container instead of the browser’s viewport. Parent
containers – those that hold other elements – frequently use the
CSS max-width property to keep from expanding beyond a certain
width while fitting within narrow viewports.
well on sites with a diverse set of layouts among its many pages
like marketing sites, ecommerce sites, news sites – anything with
more than one type of content.
2. Column drops
Thinking mobile-first, Luke’s “column drop” pattern turns a stack
of columns on its side to take advantage of additional horizontal
space in tablet and desktop-sized viewports.
Unlike other patterns, this one tends to fill the available viewport
regardless of size. This is ideal for responsively designed sites that
users will view on a very wide range of displays.
5 Useful Responsive Design Layouts 41
3. Layout shifter
Unlike the column drop pattern, Luke’s “layout shifter” uses many
breakpoints.
4. Tiny tweaks
Luke’s “tiny tweaks” pattern is the most straightforward strategy:
content, margins and padding all subtly increase with viewport
size while using the same layout. This low-maintenance approach
best serves simple, single-column designs – or designers on tight
deadlines with little budget for later adjustments.
5 Useful Responsive Design Layouts 42
5. Off-canvas
Luke’s “off-canvas” pattern pushes secondary content out of sight,
literally outside of the viewport until called upon.
Conclusion
And while exceptions to the above patterns may exist, these cover
most situations that occur across the web. Designers can choose from
these five patterns to give their layouts direction before they design
– a real head start in their work.
Responsive Navigation
In this piece, we’ll explore web design best practices through a respon-
sive lens, then explore these tactics in action with useful responsive
navigation patterns.
Touch Targets
1. Using the corners: On very small screens, the lower left corner is
the easiest place for users to access, most often with their thumb.
On tablets, which are held differently than phones, the top cor-
ners are prime touch real estate. When designing your small
screen layout, place CTA buttons or other important links in that
lower left corner to ensure ease of access. For mid-range screens,
which is where most tablets will fall, place these important but-
tons and links in those upper corners.
The only real way to define how effectively your buttons are sized is
to test them exhaustively. Use different sizes and spaces throughout
a prototype and start clicking things. See what’s easy and what’s irri-
tating. Take a lot of notes and you’ll have a good idea of what works
and what doesn’t.
Once you’ve iterated after testing the touch targets on yourself, test
with at least 5 users and then iterate again if needed.
Feedback
Users also need feedback quickly. This goes double on a touch screen.
Website visitors are notoriously impatient, mobile users even more
so. If they don’t think their actions are being processed instantly,
they’re more likely to navigate off your site. Don’t make your users
wait and guess.
Consistency
Different screen sizes and device form factors require different kinds
of website navigation. It’s a mistake to insist on absolute consistency
across the different layouts of a responsive site.
• Button size
• Visual layout
• How the navigation works, including the differences required for
touch screens. For example, a desktop navigation can sit static at
the top of a screen. When you rework the layout for the mobile
screen, you can make the navigation persistent and shrink in size
to get out of the way.
Clarity
1. Clear Labels
Specific labeling makes a huge difference in this regard. Menu
options shouldn’t be ambiguous on any level. If you want to know
more about the perks of a product or service, think about which
you’re more likely to click:
• a “Features” page
• a page labeled: “the cherry on top.”
You could even combine both the MENU label and hamburger icon
into the hybrid pattern below.
4. Navigation As Content
And finally, this is your chance to actually design navigation as
content.
For the sake of brevity, we’ll focus on 3 of the most popular types of
effective navigation. And with our final case study in this section,
we’ll give you a more solid example of what it means to design nav-
igation as content.
Smallest Viewport:
Largest Viewport:
Responsive Navigation 56
While this format is more scalable than the “Do Nothing” approach
since you just expand the footer to accommodate more items, the
transition to the bottom of the page can feel a bit jarring. You do,
however, save space in the viewing window since the navigation
is only a simple button.
Largest Viewport:
This pattern often takes over the entire screen, and has a “close” but-
ton in case the user changes his/her mind about wanting to navi-
gate away from the page. Most commonly, these drawers appear
to slide in from the left or right.
Responsive Navigation 58
Smallest Viewport:
Responsive Navigation 59
Largest Viewport:
Smallest Viewport:
Responsive Navigation 60
Largest Viewport:
4. Navigation as content:
Let the users define their own experience while making simple
links more like teasers.
than they click. If your site lends itself to a linear narrative, this
pattern is extremely effective.
Smallest Viewport:
Responsive Navigation 62
Largest Viewport:
Additional Examples
Of course, there are more than 4 ways to skin this particular cat.
Here’s a gallery of a few other common navigation patterns:
Mid-Sized Viewport:
The tablet view expands the navigation horizontally and adds a
primary CTA in the middle of the screen along with 4 secondary
CTAs at the bottom of the screen.
Responsive Navigation 64
Largest Viewport:
The navigation and content layout remain the same as the tab-
let-sized viewport.
Largest View:
Like we’ve seen with other sites, the top navigation now spreads
out horizontally. In this case, the multi-level drawer menus be-
come dropdown menus.
Now that you know the best practices, let’s apply them by building
out one of the patterns we discussed.
Prototyping the drawer used to require certain code skills, but with
the latest addition of advanced animation editor, UXPin made it as
easy as 1-2-3. It takes no more than 10 minutes to create a full-blown
navigation drawer. Let me walk you through the process step by step.
Responsive Navigation 67
2. With the canvas ready, it’s time to start designing. Add the top
bar and background using “Box” elements. The box is available
in “General Web UI library.” Using variety of UXPin’s libraries
you can quickly build whatever you want.
Responsive Navigation 68
4. When your main screen is ready, build the drawer menu. Place
it outside of the canvas. To start with, it should touch the right
edge of your main screen.
Responsive Navigation 69
5. Select every element constituting the menu and group them to-
gether (cmd+g on Macs, ctrl+g on PCs; or button in the top menu).
For easy future reference, change the group’s name “Drawer.”
Depending on your design of the “main screen” you might also
want to group to help with the fluidity of the animation.
9. You got it. Just click “save” and simulate your design using UXPin
Preview or send it directly to your mobile phone.
It’s ready!
2. Now click on your hamburger icon and enter into edit mode of
your advanced animation.
Responsive Navigation 73
Ah, swipes! They used to be impossible for prototyping tools. Not for
UXPin though! Let me walk you through the process.
1. Click on the main content group and add interaction: trigger “on
swipe left” with action: “advanced animation.”
4. Select “Drawer” from the list of layers and change its horizontal
position (you can use the top bar) to 0px.
Responsive Navigation 77
5. Now, just move the main content group to the left and click “save.”
Hope you enjoyed this tutorial. If you’d like to build your own respon-
sive prototype, go ahead and get started in UXPin with a free trial.
Responsive Typography
The written word is a top consideration on any website. It’s the way
we communicate actions, goals, functions and offerings to the user.
So it’s no surprise that legibility, readability, and overall presentation
all have a major impact on the ways that users see and understand
your designs.
• Line height, text size, and measure must all correspond propor-
tionately to the size of the screen. This requires the use of relative
units of measure (ems and rems).
Responsive Typography 79
Reading Distance
Text size hinges upon reading distance: how far the user’s eyes are
from the screen.
The requirement can obviously put you in a tough position when de-
termining text size at different breakpoints. How can you be sure how
far a reader is holding their device? Short of technology that detects
the user’s distance from the screen (and we do have top designers
Responsive Typography 80
• The further the distance between user and screen, the larger the
text should be.
• Increasing text size can give a designer fits, but don’t be discour-
aged. It’s normal to feel agitated at this sudden change. Once you’re
used to the larger size, however, you won’t be able to go smaller
in good conscience.
Ideally, your text at every breakpoint should look like it’s the same
size when held at reading distances on different devices.
Responsive Typography 81
Your font choices will undoubtedly affect the base sizing of your text.
However, 16pt body type is both the default on most browsers and
a good place to start for all screen sizes. Even so, it’s not the end-all
requirement. There’s a lot of room for experimentation, so feel free
to make small adjustments using 16pt as a baseline. For example,
since smartphones are held closer to our faces than desktops, we can
reduce the body type to 14 points (but 16 also works).
When dealing with headings, on the other hand, it’s very important
to clearly differentiate them from the body text. For all browsers,
make sure that heading text is at least 1.6 times as large as the text
supported by the headings.
Since ems compound on each other, coding your font size with ems
will require caution. Adding too many ems will result in complex and
unattractive code that doesn’t render well in every situation. And you
should be especially careful not to add ems to structural elements,
keeping their use limited to typographic elements only.
Rems are easier to control than ems, and they’re just as browser
compatible. Because they don’t have the same problems with cas-
cading, rems can behave in the same ways as ems but with fewer
complications.
Rules of thumb:
• Set base font to 100% of the browser default, rather than setting it
to a number of pixels. Doing so makes your designs more accessi-
ble to user, allowing them to customize their reading experiences.
• For displaying links or calls to action, try more than one word to
increase tappability. For example, instead of “Buy”, use “Buy Now”
or “Buy Item”. To tie back into what we discussed, more than one
word equates to roughly 5 rems.
Here’s a quick chart that shows how to set text size in terms of points
and rems. We’ll use 14 points as the smallest size for the smartphone
view. Remember that 1.6 rem is the minimum recommended for
headlines. Your headline size may be larger depending on your site’s
visual style and hierarchy.
Feel free to set your font size and rems using this handy converter tool.
Line Height
In general:
• Provided you’ve set the line height at 140%, you can keep your
line height the same across all devices.
• Line height, like text, must remain fluid in order for your text to
be responsive. Thus, it’s a good idea to define your line heights
with rems instead of pixels, just as you would normally do for your
text. 1.4 rem is preferred for body text line height and 1.2 rem is
a good size for your heading line height.
Responsive Typography 85
You can also set your line-height with unitless number values (in
other words line-height: 1 rather than line-height: 1rem). This allows
all descended elements to set their line heights relative to their own
font sizes rather than those of the root element.
Responsive Typography 86
Longer lines of text end up causing reader fatigue. They also increase
the chances of a reader reading the same line twice, which is a con-
tributing factor of reader fatigue. For these reasons, it’s advisable
to keep your measure between 45 and 85 characters regardless of
screen size.
Here are a few other rules of thumb for character counts when using
different layouts:
• For a two-column mobile view, keep the line length between 20-30
characters. When text is contained in multiple columns (on a desk-
top or tablet display) make line length between 45-60 characters.
If you need additional help with your line length choices, the Golden
Ratio Typography Calculator is a helpful online tool that can automate
your line length choices.
Conclusion
What type of website are you designing for? Where is the user’s
face likely to be in relation to the screen? Use the answers to these
questions to determine breakpoints and the accompanying text siz-
es. Remember too that line height and length must also be adjusted
proportionally to maintain the text’s legibility.
Finally, always use relative units, preferably rems, to define text size
in relation to viewport.
If you can keep these lessons in mind and as always test to iron out
inconsistencies, then you’ll be well on your way to attractively ren-
dering, always legible, readable, and completely fluid typography.
Responsive Images
Web design isn’t cheap. It costs effort to produce and time to learn.
And tools, like that fancy new Mac and Adobe’s software subscrip-
tion model, eat away at profits. But of all web design’s costs to the
designer, it’s the user’s costs we should consider first.
Mobile users often pay for every byte they download (and upload)
away from wifi. HTML and CSS files, while getting larger every year,
aren’t as large as hefty JPG, PNGs and animated GIFs. Conscientious
designers know that best practice includes making websites and apps
that download as quickly as possible. It’s like trimming out extra ad-
verbs from copy, or extra div elements from markup.
JPG, SVG, GIF and PNG (and PNG-24) – anyone new to web design
may confuse the three. That’s not surprising when even seasoned
veterans opt for JPG when a SVG would do, or default for PNG-24
instead of PNG-8.
1. JPG
Or JPEG, short for Joint Photographic Experts Group, was developed
in 1991 and published in 1992 as a means to standardize pictures
transmitted over the internet. Bandwidth was at a premium, so
users prefered files that showed more picture for fewer bytes.
The JPG format uses lossy compression, meaning that once applied,
an image can never be fully decompressed back to the original
quality. It trades smaller files for reduced quality on a scale of 0
– 100. Oddly, files with 100% JPG compression have the highest
quality and the worst file size. 0% compression yields the smallest
files with the worst quality.
Responsive Images 90
2. PNG (8-bit)
Unlike JPG, Portable Network Graphics files use lossless compression
that doesn’t compound as the file is opened and resaved. Instead,
PNG-8 files include a list of every unique color they use.
The PNG-8 format can hold up to 256 unique colors in its list, called
a color table. It can also make pixels fully transparent. These facts
make PNG-8 ideal for today’s trendy “flat color” look.
3. PNG (24-bit)
Files that use PNG’s other variety, PNG-24, look great because they
use no compression. Nor do they use a color table. Every detail
is preserved when saving PNG-24 files... and that’s the problem.
4. GIF
Graphical Interchange Format, or GIF, resembles PNG-8 in many
ways.
Where GIFs shine is their ability to hold more than one “image” per
file, and show them sequentially. That is, GIF supports animation.
Animated GIF files usually find their way into content more than
design, as their animations can’t be started and stopped – they’re
not truly interactive. That and their slightly-higher file sizes mean
that designers often prefer PNG over GIF for flat-color images.
Compression Services
1. Compress JPG
As the name implies, this free, online service by Mediafox Market-
ing takes extra bytes out of any JPG file without sacrificing quality.
Responsive Images 94
2. TinyPNG
Another free service – this one from voormedia – squeezes 8-bit
and 24-bit PNG files for faster load times.
For JPGs
To find out, we saved the crowd photo above with increments of
JPG compression. Results ranged from 45KB at 0% compression
to 479KB at 100%. Contrary to what the term suggests, remember
that the highest compressed JPGs have the highest quality (and
largest file size).
Responsive Images 95
Best practice: Do not compress JPG files higher than 70%, or lower
than 20%. This is a guideline rather than a hard rule, but we’ve
found it the 20–70 range covers most cases.
For PNGs
The story gets more complicated when we look at PNG files. We
ran the same experiment on this graphic:
Notice that these colors aren’t strictly flat. There’s a fine gradient
over the entire composition. To account for that, we need dither-
ing: a pattern of dots that simulate subtle gradients.
Responsive Images 97
Unlike JPG, the PNG format doesn’t use percentages. The number
of colors in its color table determine its quality and, to an extent,
its file size. With 88% dithering, the results were, well...
Best practice: For best results when squeezing every byte out of
a PNG, the best approach is to experiment with different color
tables. Unfortunately the right amount is a subjective matter that
varies per image. When it looks “right” is up to you.
4. SVG
Scalable Vector Graphics, or SVG, use lines instead of pixels – vec-
tors instead of raster images – to display line art. SVGs are actu-
ally a form of XML, easily created in programs like Inkscape and
Adobe Illustrator.
Above: vector art (left) scales up well. On the other hand, raster art
(right) looks blocky and pixelated.
Responsive Images 99
But like PNGs and GIFs, SVGs suffer as images become more com-
plex. They’re terrible for photos and grow quickly in file size as
they gain points and curves.
If you’re looking for the flat 2.0 look, with its sharp lines and gentle
gradients, and aim for recent browsers (IE8 is out of luck), SVGs
are the way to go.
Code Considerations
Aside from image files themselves, we can do lots with code to make
pixels respond well to different situations.
This selector and property makes most images fit into their con-
tainers. For example, if a media query sets a wrapper to 300 pixels
in width, then no image inside that wrapper will exceed 300 pixels.
This technique has excellent support across modern browsers,
which is why you’ll find it in many responsive websites today.
As a bonus, browsers that don’t support <picture> will still read the
default <img> element as normal. That’s good news because, at the
time of this writing, these elements are not universally accepted
– in fact, few modern browsers support them today. But support
for <picture> and <source> is growing, and smart designers will
keep an eye out for their usage in the future.
3. Browser rendering
Sometimes the best image is none at all. Modern browsers are
capable of rendering their own graphics, including gradients,
animations, bezier vectors, shadows and geometric shapes. With
a little creativity, we can even make stripes.
Responsive Images 101
In a perfect world we’d have the ability to either crop an image for
smaller viewports, focusing on the most important parts, or the abil-
ity to upload different images for different breakpoints. It is possible
to do so. Workarounds exist, and we look forward to <picture> and
srcset. Until then the best-practice approach is to test your images at
various sizes to make sure they’re readable on various devices and
browsers.
(but not too much) and watching future technologies go a long way to
making websites load quickly and look great on screens of any size,
resolution or orientation.
It all comes down to one question: what serves the user best?
The Technical Side of
Responsive Design
Let’s review the fundamentals. CSS works with selectors and properties.
• Values: the change itself. Examples: Red, 10px and sans-serif are
three values.
Now let’s put this together. “div { color: #333; }” has one selector, one
property and one value.
How do we define these rules? Media queries. Media queries are CSS
commands that determine under what conditions other CSS selectors
take effect.
For example, one media query might tell a browser, “pay attention to
rules 1–10 when the screen is up to 320 pixels wide,” while another
might say, “pay attention to rules 11–20 when the screen is 321 pixels
wide or greater.”
The Technical Side of Responsive Design 105
Media queries are easy to identify: they begin with “@media”. Brows-
ers read the CSS rules (e.g. selectors) listed between the media query’s
{ curly brackets }.
Above, CSS says to make all text red on visual devices, not screen
readers.
Rules take effect on visual devices that display exactly 320 pixels
horizontally.
It says that any color screen at least 480 pixels wide, held in landscape
position, with an aspect ratio of 4 to 3 that’s exactly 320 pixels wide
should take on certain properties.
The two most popular conditions are minimum and maximum width,
the upper and lower limits a browser window can be to take on the
given properties. But we can manipulate other important properties.
“High-density images” are those that use more device pixels (actual
dots a browser can display) vs. those defined in CSS. That means
for an image to look its best, it needs four times the usual number
of pixels. Something displayed at 300×300 pixels on a small screen
actually needs 600×600 pixels total – when our media queries detect
high-res screens.
For now, though, width and resolution are most useful for responsive
web design. Since contemporary site design lets us scroll up and down,
width determines the available space a layout can use.
The Technical Side of Responsive Design 108
Here’s where media queries help us most: they allow us to plan for
browsers based on content and capability, not expectations. That
is, we can tell browsers that our designs look best under ranges
of conditions, like 0–300 pixels vs. 301 – 600 pixels, and write our
code to suit our needs rather than what the browser requires.
Like images, we can shrink CSS files to use as few bytes as possible.
Smaller files require less time to load, making websites faster and
keeping users from wandering away.
1. Minification
With good spacing, CSS and HTML files are easy for designers
to develop and maintain. But browsers don’t care about spaces
between elements, properties and selectors. Extra spaces mean
extra bytes, so we want to minimize those spaces (hence the term).
Before:
body {
background: #fff;
color: #444;
}
p{
padding-bottom: 1rem;
margin: 0;
}
After:
body{background:#fff;color:#444}p{padding-bottom:1rem;margin:0}
The Technical Side of Responsive Design 110
Best practice: check your code and always minify copies of your
HTML, CSS and JavaScript files before uploading them to the live
website.
2. GZIP
Like LZW compression used in PNG and GIF files, GZIP scans files
for redundant bytes. This is a deeper compression technique than
minification. Google reports that this works best with text-based
files like HTML, CSS and JavaScript.
Best practice: zip files after minifying them to make sites load
faster, especially on smaller, less-capable devices.
HTTP requests
Best Practices) users start losing their feeling of control after a 1-2
second delay.
Once again, the advantage here is speed, especially for small devices
with limited bandwidth or slow connections.
Takeaway
Based on Brad Frost’s atomic design framework, map out your overall
layout in a wireframe or lo-fi prototype, then start refining details of
components reused through the design. Involve developers so you
can start laying out the groundwork as early as possible.
Test, test and test again as you design. Use real devices – don’t assume
your mouse cursor is the same experience as a fingertip. Invite de-
velopers to any usability testing sessions so they can start to grasp
the technical implications of the necessary revisions.
If you’re a designer who handles the development, you can try the
following tactics as well:
Putting It All Together: The Mobile-First Workflow 114
Helpful resources:
Mobile-First = Content-First
These presets layout the proper screen size for you, so you can wire-
frame keeping only the content in mind.
Test your design with at least 5 real users. When we’re designing
responsively in UXPin, we’ll use the app’s SMS or QR code function
to send the prototype to our mobile device. After completing any
necessary tweaks, we’ll then create user tasks and use the remote
usability testing feature in UXPin to validate the design. Since the
entire session is recorded, we can see all the clicks and feedback for
future reference. You can either run your own similar test or use a
paid service like User Testing.
Putting It All Together: The Mobile-First Workflow 120
8. Gift certificates
9. A testimonial
10. The latest blog post
Based on that ordered list, we can create with the confidence that
our work will solve a design problem of getting sales.
On setting breakpoints
At what point should we set breakpoints? As we’ve seen, the an-
swers vary quite a bit. But there are some rules of thumb.
means the text, images and media for which users visit our sites
to begin with.
Smartphone View:
Tablet View:
Resist the urge. Use the ordered content list. Like smartphones,
space is still limited.
Desktop View:
• Gift certificates
• Customer testimonials
• Blog post exploring the newest Lightning Bolt bike
Putting It All Together: The Mobile-First Workflow 125
Going forward
Nothing beats practice. Test it. Seek outside opinions, and not just
from other designers – get folks to try your work. Collaborate with
your team. And stay flexible in your thinking to make your designs
work well on browsers of any configuration.
Everything you ever wanted
in a UX Design Platform
www.uxpin.com