Find out where responsive design came from.
Right from the start, the World Wide Web was designed to be agnostic. It doesn't matter what hardware you've got. It doesn't matter what operating system your device is running. As long as you can connect to the internet, the World Wide Web is accessible to you.
In the early days of the web, most people were using desktop computers. These days the web is available on desktops, laptops, tablets, foldable phones, fridges, and cars. People rightly expect that websites will look good no matter what device they're using. Responsive design makes this possible.
Responsive design isn't the first approach to designing websites. In the years before responsive design, web designers and developers tried many different techniques.
Fixed-width design #
In the early 1990s, when the web was first becoming popular, most monitors had screen dimensions of 640 pixels wide by 480 pixels tall. These were convex cathode ray tubes, not like the flat liquid crystal displays we have now.
In the formative days of early web design, it was a safe bet to design web pages with a width of 640 pixels. But while other technologies like phones and cameras were miniaturizing, screens were getting bigger (and eventually, flatter). Before long, most screens had dimensions of 800 by 600 pixels. Web designs changed accordingly. Designers and developers started assuming that 800 pixels was a safe default.
Then the screens got bigger again. 1024 by 768 became the default. It felt like an arms race between web designers and hardware manufacturers.
Whether it was 640, 800, or 1024 pixels, choosing one specific width to design for was called fixed-width design.
If you specify a fixed width for your layout, then your layout will only look good at that specific width. If a visitor to your site has a wider screen than the width you have chosen, then there'll be wasted space on the screen. You can center the content of your pages to distribute that space more evenly (instead of having empty space on one side) but you still wouldn't be taking full advantage of the available space.
Similarly, if a visitor arrives with a narrower screen than the width you've chosen, then your content won't fit horizontally. The browser generates a crawlbar—the horizontal equivalent of a scrollbar—and the user has to move the whole page left and right to see all the content.
Liquid layouts #
While the majority of designers used fixed-width layouts, some chose to make their layouts flexible. Instead of using fixed widths for your layouts you could make a flexible layout using percentages for your column widths. These designs work in more situations than a fixed-width layout that only looks right at one specific size.
These were called liquid layouts. But while a liquid layout will look good across a wide range of widths, it will begin to worsen at the extremes. On a wide screen the layout looks stretched. On a narrow screen the layout looks squashed. Both scenarios aren't ideal.
You can mitigate these problems by using
max-width for your layout. But then at any size below the minimum width or above the maximum width you've got the same issues you'd have with a fixed-width layout. On a wide screen there'd be unused space going to waste. On a narrow screen, the user would have to move the whole page left and right to see everything.
The word liquid is just one of the terms used to describe this kind of layout. These kinds of designs were also called fluid layouts or flexible layouts. The terminology was as fluid as the technique.
Small screens #
In the 21st century, the web continued to get bigger and bigger. So did monitors. But new screens arrived that were smaller than any desktop device. With the arrival of mobile phones with fully-featured web browsers, designers faced a dilemma. How could they ensure their designs would look good on a desktop computer and a mobile phone? They needed a way of styling their content for screens as small as 240 pixels wide and as large as thousands of pixels wide.
Separate sites #
One option is to make a separate subdomain for mobile visitors. But then you have to maintain two separate codebases and designs. And in order to redirect visitors on mobile devices, you'd need to do user-agent sniffing, which can be unreliable and easily spoofed. Chrome will be deprecating its user-agent string for privacy reasons. Also, there's no clear line between mobile and not-mobile. Which site do you send tablet devices to?
Adaptive layouts #
Instead of having separate sites on different subdomains, you could have a single site with two or three fixed-width layouts.
When media queries first arrived in CSS, they opened the door to making layouts more flexible. But many developers were still most comfortable making fixed-width layouts. One technique involved switching between a handful of fixed-width layouts at specified widths. Some people call this an adaptive design.
Adaptive design allowed designers to provide layouts that looked good at a few different sizes, but the design never looked quite right when viewed between those sizes. The problem of excess space persisted although it wasn't as bad as in a fixed-width layout.
Using CSS media queries, you can give people the layout that's closest to their browser width. But given the variety of device sizes, chances are the layout will look less than perfect for most people.
Responsive web design #
If adaptive layouts are a mashup of media queries and fixed-width layouts, responsive web design is a mashup of media queries and liquid layouts.
Ethan defined three criteria for responsive design:
- Fluid grids
- Fluid media
- Media queries
The layout and images of a responsive site would look good on any device. But there was one problem.
meta element for
Browsers on mobile phones had to deal with websites that were designed with fixed-width layouts for wider screens. By default mobile browsers assumed that 980 pixels was the width that people were designing for (and they weren't wrong). So even if you used a liquid layout, the browser would apply a width of 980 pixels and then scale the rendered web page down to the actual width of the screen.
If you're using responsive design you need to tell the browser not to do that scaling. You can do that with a
meta element in the
head of the web page:
<meta name="viewport" content="width=device-width, initial-scale=1">
There are two values, separated by commas. The first one is
width=device-width. This tells the browser to assume the width of the website is the same as the width of the device (instead of assuming the width of the website is 980 pixels). The second value is
initial-scale=1. This tells the browser how much or how little scaling to do. With a responsive design, you don't want the browser to do any scaling at all.
meta element in place, your web pages are ready to be responsive.
Modern responsive design #
Today we have the ability to make websites that are responsive in ways far beyond viewport sizes. Media features give developers access to user preferences and enable customized experiences. Container queries enable components to own their own responsive information. The
picture element empowers designers to make art-direction decisions based on screen ratios.
In 2021, it's a safe bet to design web pages at a fixed width?true false
It's unsafe to bet on fixed width design in 2021.
🎉 Correct! The number of possible screen sizes is too great to assume visitors will come from one size.
Liquid layouts generally struggle at which kind of screen sizes?Narrow screens Average screens Wide screens Short screens Tall screens All screens
🎉 Correct! The extreme size of a narrow display can make liquid layouts appear squished.
Try again. Liquid layouts do well on average sized screens.
🎉 The extreme size of a wide, or even ultrawide, display can make liquid layouts appear stretches out to uncomfortable reading lengths.
Try again. Short screens generally do not struggle to support liquid layouts.
Try again. Tall screens generally do not struggle to support liquid layouts.
Try again. Liquid layouts are a great choice for many screen sizes.
The original three criteria for responsive design are?Fluid typography Fluid grids Adaptive grids Fluid media Fixed width design Media Queries
Try again! Fluid typography was not one of the initial criteria.
Try again! An adaptive grid changes based on set viewport sizes.
Try again! Fixed width designs refers to a design with a set, unresponsive width.
Responsive design is an exciting, growing world of possibilities. In the rest of this course, you'll learn about these technologies and how to use them to create beautiful, responsive websites for everyone.