In his A Dao of Flexibility talk at An Event Apart in Minneapolis, MN Ethan Marcotte walked through a number of techniques for creating context-sensitive Web designs that work across multiple devices and screen resolutions effectively. Here's my notes from his presentation:
- The more tightly you try to control something the more you ultimately begin to loose control. There is a tension between how we’ve tried to develop for the Web and how the Web should be.
- Most terms used to describe Web design stem from the world of print. The most important concept may be the canvas. It creates a boundary of where your design can go.
- When doing Web design, we set up a blank canvas in Photoshop but it is far removed from the realities of the browser where we don’t even have definitive width and height. To deal with this we set constraints but they are fragile. If things stray beyond the artificial limits we establish, important elements can fall off.
- Instead of seeing the uncertainty of the browser as its greatest weakness, we should see it as a greatest strength. We should embrace the medium and accept the ebb and flow of things.
- The number of ways/devices that allow us to connect to content online is unprecedented. Mobile Web access is going to eclipse desktop Web access in 3 to 5 years. The iPhone and iPod Touch have outpaced the adoption AOL and Netscape dramatically.
- Are we going to develop a quarantined Website for every device or will we develop a flexible system that works appropriately for several experiences.
Responsive Design
- Responsive architecture tries to challenge the permanence of physical spaces. Buildings, walls, and physical elements can adjust over time. This is a continual and constructive information exchange. The space and the occupants should both inform each other. How can a space redefine itself to meet the needs of the people that occupy it?
- Responsive Web design tries to build on these principles through three basic components: a flexible grid (and flexible images) that incorporates media queries to create responsive, adaptive designs.
- The flexible grid: uses proportional healing to adapt. Designers argued that a rational design grid framework would help layout and readers. The problem was all these grids were fixed-width.
- How do we take something designed in an image editor and allow it to grow and breathe within the browser window?
- Steps in converting a layout: identify different kinds of elements (headline, article, etc.); define a simple mark-up structure based on these elements; set basic presentation styles for the content; apply more detailed styles to these core elements.
- By default most browsers ship with 16pixels set as default font size. Set fonts to 100% in a default style sheet so that you can scale your content from this baseline.
- Every single element in a grid can be specified proportionally. “Target divided by context equals result” can help you set ratios for the elements of your site. Use ems for font sizing. To get the em size that you want instead of pixels, you divide the target size by the context font size. This will give you the new em value to use. Don't worry about decimals, you can drop those right in.
- We’ve been focused on pixel-based sizing but ratios are more flexible across the multiple devices designers need to support.
- Instead of setting widths in pixels, set them in proportions.
- You can set images to work in a flexible context by using: img {max-width: 100%} This means the image will never exceed the size of its containing element (in modern browsers). This rule extends well to other forms of media as well like videos.
- Max-width is not supported in IE6 and lower. There are a couple of ways to deal with this. One uses a separate IE6 style sheet to set images and videos to width: 100%. This is a bit dangerous so tread carefully.
- Internet Explorer’s proprietary CSS filters can help make resized images look good in IE7. AlphaImageLoader clears up artifacting. There is no way to fix the artifacting issue in FireFox 2.
Media Queries
- No design, flexible or fixed scales well beyond the context in which it was designed. Issues especially start to show up when you change form factors (mobile, TV). How do our designs respond to different devices and resolutions?
- CSS2 defined media types to load in different style sheets appropriate for a context. This specification was not really embraced.
- Media queries are like media types on steroids. These query for media parameters and serve up different CSS. You can detect colors, orientation, aspect ratios, and more.
- Media queries allow you to design for optimal viewing resolutions.
- Multiple media queries can inherit from one another. When you have a max-width rule for 320px and 640px, the smaller one will render the 640 rules as well because both are under 640px.
- When you move below modern browsers, CSS media query support is spotty but you can use Javascript libraries to develop support.
- You can see Ethan’s flexible designs at Robot or Not
- The use case for fixed width designs is running its course. Design for the flexibility inherent in the medium.