3 fundamentals of responsive design you have to master

Default avatar.
October 17, 2014
3 fundamentals of responsive design you have to master.
thumbnailA few years ago, it was relatively easy to design and build websites. Websites were simpler, and were viewed on desktops and laptops with little variation in screen sizes. Today with mobile devices taking over viewers’ browsing time, a website can be viewed on a 4.8” smartphone screen, a 5” phablet, a 7” tablet or any size in between. So how do you ensure your website displays correctly across device types and screen sizes? The solution was first proposed by Ethan Marcotte, when he explored ways to make website designs responsive, i.e. have them change according to the screen size. A responsive website design is one which makes clever use of CSS to ensure that web pages render well across a wide range of screen sizes – without resorting to URL redirection or dynamically serving different HTML and CSS code, depending on the UserAgent. It’s not really a technology or a standard, but rather a set of design principles that help achieve the result. Over the last few years, many responsive templates, CSS frameworks and WordPress themes have sprung up. It is, for example, possible to create a responsive website in WordPress without writing a single line of code. But a real web designer isn’t satisfied with just using the templates. She’ll make the effort to understand the elements of responsive web design, in order to use them effectively. So today, we’re going to look at the 3 fundamental techniques you need to master, you be an effective responsive designer.

1. Media queries

Media queries let you design different layouts for different media types like screen, print, TV, handheld devices etc. Depending on the media type, you can configure the style, the font and other elements of the page. Introduced in CSS3, media queries let a designer customize the presentation of the content to suit a specific range of output device types. They consist of a media type declaration and one or more media feature expressions that evaluate to true or false. The range of media types include handheld, screen, tv, print and projection. Media features include, but are not limited to device height, width, aspect ratio, resolution, color index as well as height, width of the browser window. Let’s take a basic example; imagine you want your text size to shrink on smaller devices, like phones. The query for that would look something like:
p {

@media all and (max-width:400px) {
 p {
Now, the font size of your paragraphs will be set to 1em, unless the browser width is less than 400px, in which case it will shrink to 0.8em. In my experience, the best way to design a responsive layout is to first create a default master style sheet with the main structural elements. Then you can add in media queries to customize elements based on the layout or other device elements. If it’s more than a handful of rules, it might be better to move them out to a separate child sheet — which you can selectively load later. Here’s how that would work:
<link rel="stylesheet" type="text/css" media="handheld and (orientation:landscape) and (max-device-width: 720px)" href="tablet_layout.css" />
This piece of code checks whether the device is a handheld in landscape mode with device width less than 720px, and if so, it loads the tablet_layout.css stylesheet. Note that the features width, height, min/max-width, min/max-height all refer to the browser window’s width and height. The device width and height are controlled by the device-width, device-height, min/max- device-width, min/max- device-height. If you’d like to look up more examples using media queries MDN has a good round up.

2. Fluid grids

“Fluid grid” is a term used to describe a layout that is coded in relative proportions of the various elements, rather than with fixed pixel values. Traditional CSS layouts used fixed width grids to position the elements. The fixed-width approach no longer works today now that we have device screens ranging from 3 inches to a few feet. In a fluid grid design, everything is coded in terms of its relative proportion to the base element i.e. instead of specifying the height and width of each element; it is given a percentage or relative size. Imagine you have four columns. To make this fluid, instead of specifying each as 200 pixel wide, you’d have to specify them 0.2083 % (ie as 200/960). At least, that’s the principle. Creating an entirely fluid grid requires much care. It’s one of those rare cases I’d rather recommend using custom tools. Tiny Fluid Grid, Variable Grid System and Fluid Baseline Grid are some great alternatives to writing your own fluid grid from scratch.

3. Flexible images

Images are deemed flexible when the image renders in native size, as long as the HTML container supports it, but when the browser window shrinks, the image scales to fit it. Even if the rest of the design is fluid and responsive, it’s not going to render well, if all components don’t scale. This can get tricky with images and videos. A 700 pixel wide image will look great on a desktop, but get chopped off when viewed on a 320 pixel tablet. Most modern responsive designs use the CSS max-width property to make images scale. (This method was first proposed by Richard Butler.)
img {
 max-width: 100%;
These few lines will ensure that the image doesn’t get chopped off, by setting the max image width to 100% of the container. If the browser window or screen becomes smaller, this piece of CSS code will shrink the image proportionately. The height is automatically adjusted, while keeping the aspect ratio locked. You can instead, lock the image to occupy a certain vertical screen proportion like this
img {
 max-height: 75%;
(Make sure not to use both max-height and max-width properties together. ) The image size can also be linked to the text size instead of the parent element using em, like this:
img {
 width: 30em;
If the image contains text, you may want to limit the minimum/maximum size, to ensure that the text is readable. You can specify it like this:
img {
 width: 30em;
 max-width: 500px;
 min-width: 100px;
The same techniques can be used to scale videos, for example:
.video embed, .video object, .video iframe { width: 100%; height: auto; }

Final thoughts

Responsive design is the future of our industry, but with so many different techniques flying around, it’s often hard to keep up. Master these 3 simple techniques, and you’ll be 90% of the way to being a responsive designer. Featured image/thumbnail, elastic image via Shutterstock.

Richa Jain

Read Next

Surviving the Leap from College to Real-World Design

So, you’ve finished college and are ready to showcase your design skills to the world. This is a pivotal moment that…

20 Mind-Bending Illusions That Will Make You Question Reality

Mind-bending videos. Divisive Images. Eye-straining visuals. This list of optical illusions has it all. Join us as we…

15 Best New Fonts, February 2024

Welcome to February’s roundup of the best new fonts for designers. This month’s compilation includes some innovative…

The 10 Best WordPress Quiz Plugins in 2024

Whether it’s boosting your organic search visibility or collecting data for targeted email marketing campaigns, a great…

20 Best New Websites, February 2024

It’s almost Valentine’s Day, so this latest collection is a billet-doux celebrating the best of the web this month.

Everything You Need to Know About Image Formats In 2024

Always trying to walk the tightrope between image quality and file size? Looking to branch out from JPGs and PNGs this…

The 10 Best Logos of 2023 - Ranked

From vintage aesthetics to innovative new color schemes, we’ve seen a lot of creative logo designs this year. In this…

Exciting New Tools for Designers, February 2024

2024 is well underway and shaping up to be an interesting year. So, to help you keep your focus on working hard and…

The Art of Engineering AI Prompts

In the rapidly evolving world of artificial intelligence, the ability to communicate effectively with AI tools has…

15 Best New Fonts, January 2024

In this month’s roundup of the best new fonts, we find a large number of vintage, retro, and revival typefaces. Is it…

5 Web Design Disasters That Will Ruin Your 2024

Welcome to 2024, where web design is as fast-paced as ever. You know how crucial a killer website is nowadays — your…

14 Best Free SEO Tools in 2024

There is an ongoing debate about whether design is more art or more science. SEO is 100% alchemy; if you know where to…