Saturday, March 31, 2012

Design Thinking for Social Innovation

Design Thinking for Social Innovation

In an area outside Hyderabad, India, between the suburbs and the countryside, a young woman—we’ll call her Shanti—fetches daily from the always-open local borehole that is about 300 feet from her home. She uses a 3-gallon plastic container that she can easily carry on her head. Shanti and her husband rely on the free water for their drinking and washing, and though they’ve heard that it’s not as safe as water from the Naandi Foundation-run community treatment plant, they still use it. Shanti’s family has been drinking the local water for generations, and although it periodically makes her and her family sick, she has no plans to stop using it.
image Shanti has many reasons not to use the water from the Naandi treatment center, but they’re not the reasons one might think. The center is within easy walking distance of her home—roughly a third of a mile. It is also well known and affordable (roughly 10 rupees, or 20 cents, for 5 gallons). Being able to pay the small fee has even become a status symbol for some villagers. Habit isn’t a factor, either. Shanti is forgoing the safer water because of a series of flaws in the overall design of the system.
Although Shanti can walk to the facility, she can’t carry the 5-gallon jerrican that the facility requires her to use. When filled with water, the plastic rectangular container is simply too heavy. The container isn’t designed to be held on the hip or the head, where she likes to carry heavy objects. Shanti’s husband can’t help carry it, either. He works in the city and doesn’t return home until after the water treatment center is closed. The treatment center also requires them to buy a monthly punch card for 5 gallons a day, far more than they need. “Why would I buy more than I need and waste money?” asks Shanti, adding she’d be more likely to purchase the Naandi water if the center allowed her to buy less.
The community treatment center was designed to produce clean and potable water, and it succeeded very well at doing just that. In fact, it works well for many people living in the community, particularly families with husbands or older sons who own bikes and can visit the treatment plant during working hours. The designers of the center, however, missed the opportunity to design an even better system because they failed to consider the culture and needs of all of the people living in the community.
This missed opportunity, although an obvious omission in hindsight, is all too common. Time and again, initiatives falter because they are not based on the client’s or customer’s needs and have never been prototyped to solicit feedback. Even when people do go into the field, they may enter with preconceived notions of what the needs and solutions are. This flawed approach remains the norm in both the business and social sectors.
As Shanti’s situation shows, social challenges require systemic solutions that are grounded in the client’s or customer’s needs. This is where many approaches founder, but it is where design thinking—a new approach to creating solutions—excels.
Traditionally, designers focused their attention on improving the look and functionality of products. Classic examples of this type of design work are Apple Computer’s iPod and Herman Miller’s Aeron chair. In recent years designers have broadened their approach, creating entire systems to deliver products and services.
Design thinking incorporates constituent or consumer insights in depth and rapid prototyping, all aimed at getting beyond the assumptions that block effective solutions. Design thinking—inherently optimistic, constructive, and experiential—addresses the needs of the people who will consume a product or service and the infrastructure that enables it.
Businesses are embracing design thinking because it helps them be more innovative, better differentiate their brands, and bring their products and services to market faster. Nonprofits are beginning to use design thinking as well to develop better solutions to social problems. Design thinking crosses the traditional boundaries between public, for-profit, and nonprofit sectors. By working closely with the clients and consumers, design thinking allows high-impact solutions to bubble up from below rather than being imposed from the top.


Design Thinking at Work
Jerry Sternin, founder of the Positive Deviance Initiative and an associate professor at Tufts University until he died last year, was skilled at identifying what and critical of what he called outsider solutions to local problems. Sternin’s preferred approach to social innovation is an example of design thinking in action.1 In 1990, Sternin and his wife, Monique, were invited by the government of Vietnam to develop a model to decrease in a sustainable manner high levels of malnutrition among children in 10,000 villages. At the time, 65 percent of Vietnamese children under age 5 suffered from malnutrition, and most solutions relied on government and UN agencies donations of nutritional supplements. But the supplements—the outsider solution—never delivered the hoped-for results.2 As an alternative, the Sternins used an approach called positive deviance, which looks for existing solutions (hence sustainable) among individuals and families in the community who are already doing well.3
The Sternins and colleagues from Save the Children surveyed four local Quong Xuong communities in the province of Than Hoa and asked for examples of “very, very poor” families whose children were healthy. They then observed the food preparation, cooking, and serving behaviors of these six families, called “positive deviants,” and found a few consistent yet rare behaviors. Parents of well-nourished children collected tiny shrimps, crabs, and snails from rice paddies and added them to the food, along with the greens from sweet potatoes. Although these foods were readily available, they were typically not eaten because they were considered unsafe for children. The positive deviants also fed their children multiple smaller meals, which allowed small stomachs to hold and digest more food each day.
The Sternins and the rest of their group worked with the positive deviants to offer cooking classes to the families of children suffering from malnutrition. By the end of the program’s first year, 80 percent of the 1,000 children enrolled in the program were adequately nourished. In addition, the effort had been replicated within 14 villages across Vietnam.4
The Sternins’ work is a good example of how positive deviance and design thinking relies on local expertise to uncover local solutions. Design thinkers look for work-arounds and improvise solutions—like the shrimps, crabs, and snails—and they find ways to incorporate those into the offerings they create. They consider what we call the edges, the places where “extreme” people live differently, think differently, and consume differently. As Monique Sternin, now director of the Positive Deviance Initiative, explains: “Both positive deviance and design thinking are human-centered approaches. Their solutions are relevant to a unique cultural context and will not necessarily work outside that specific situation.”
One program that might have benefited from design thinking is mosquito net distribution in Africa. The nets are well designed and when used are effective at reducing the incidence of malaria.5 The World Health Organization praised the nets, crediting them with significant drops in malaria deaths in children under age 5: a 51 percent decline in Ethiopia, 34 percent decline in Ghana, and 66 percent decline in Rwanda.6 The way that the mosquito nets have been distributed, however, has had unintended consequences. In northern Ghana, for instance, nets are provided free to pregnant women and mothers with children under age 5. These women can readily pick up free nets from local public hospitals. For everyone else, however, the nets are difficult to obtain. When we asked a well-educated Ghanaian named Albert, who had recently contracted malaria, whether he slept under a mosquito net, he told us no—there was no place in the city of Tamale to purchase one. Because so many people can obtain free nets, it is not profitable for shop owners to sell them. But hospitals are not equipped to sell additional nets, either.
As Albert’s experience shows, it’s critical that the people designing a program consider not only form and function, but distribution channels as well. One could say that the free nets were never intended for people like Albert—that he was simply out of the scope of the project. But that would be missing a huge opportunity. Without considering the whole system, the nets cannot be widely distributed, which makes the eradication of malaria impossible.




The Origin of Design Thinking
IDEO was formed in 1991 as a merger between David Kelley Design, which created Apple Computer’s first mouse in 1982, and ID Two, which designed the first laptop computer, also in 1982. Initially, IDEO focused on traditional design work for business, designing products like the Palm V personal digital assistant, Oral-B toothbrushes, and Steelcase chairs. These are the types of objects that are displayed in lifestyle magazines or on pedestals in modern art museums.
By 2001, IDEO was increasingly being asked to tackle problems that seemed far afield from traditional design. A healthcare foundation asked us to help restructure its organization, a century-old manufacturing company wanted to better understand its clients, and a university hoped to create alternative learning environments to traditional classrooms. This type of work took IDEO from designing consumer products to designing consumer experiences.
To distinguish this new type of design work, we began referring to it as “design with a small d.” But this phrase never seemed fully satisfactory. David Kelley, also the founder of Stanford University’s Hasso Plattner Institute of Design (aka the “d.school”), remarked that every time someone asked him about design, he found himself inserting the word “thinking” to explain what it was that designers do. Eventually, the term design thinking stuck.7
As an approach, design thinking taps into capacities we all have but that are overlooked by more conventional problem-solving practices. Not only does it focus on creating products and services that are human centered, but the process itself is also deeply human. Design thinking relies on our ability to be intuitive, to recognize patterns, to construct ideas that have emotional meaning as well as being functional, and to express ourselves in media other than words or symbols. Nobody wants to run an organization on feeling, intuition, and inspiration, but an over-reliance on the rational and the analytical can be just as risky. Design thinking, the integrated approach at the core of the design process, provides a third way.
The design thinking process is best thought of as a system of overlapping spaces rather than a sequence of orderly steps. There are three spaces to keep in mind: inspiration, ideation, and implementation.Think of inspiration as the problem or opportunity that motivates the search for solutions; ideation as the process of generating, developing, and testing ideas; and implementation as the path that leads from the project stage into people’s lives.
The reason to call these spaces, rather than steps, is that they are not always undertaken sequentially. Projects may loop back through inspiration, ideation, and implementation more than once as the team refines its ideas and explores new directions. Not surprisingly, design thinking can feel chaotic to those doing it for the first time. But over the life of a project, participants come to see that the process makes sense and achieves results, even though its form differs from the linear, milestone-based processes that organizations typically undertake.




Inspiration
Although it is true that designers do not always proceed through each of the three spaces in linear fashion, it is generally the case that the design process begins with the inspiration space—the problem or opportunity that motivates people to search for solutions. And the classic starting point for the inspiration phase is the brief. The brief is a set of mental constraints that gives the project team a framework from which to begin, benchmarks by which they can measure progress, and a set of objectives to be realized—such as price point, available technology, and market segment.
But just as a hypothesis is not the same as an algorithm, the brief is not a set of instructions or an attempt to answer the question before it has been posed. Rather, a well-constructed brief allows for serendipity, unpredictability, and the capricious whims of fate—the creative realm from which breakthrough ideas emerge. Too abstract and the brief risks leaving the project team wandering; too narrow a set of constraints almost guarantees that the outcome will be incremental and, likely, mediocre.
Once the brief has been constructed, it is time for the design team to discover what people’s needs are. Traditional ways of doing this, such as focus groups and surveys, rarely yield important insights. In most cases, these techniques simply ask people what they want. Conventional research can be useful in pointing toward incremental improvements, but those don’t usually lead to the type of breakthroughs that leave us scratching our heads and wondering why nobody ever thought of that before.
Henry Ford understood this when he said, “If I’d asked my customers what they wanted, they’d have said ‘a faster horse.’” 8 Although people often can’t tell us what their needs are, their actual behaviors can provide us with invaluable clues about their range of unmet needs.
A better starting point is for designers to go out into the world and observe the actual experiences of smallholder farmers, schoolchildren, and community health workers as they improvise their way through their daily lives. Working with local partners who serve as interpreters and cultural guides is also important, as well as having partners make introductions to communities, helping build credibility quickly and ensuring understanding. Through “homestays” and shadowing locals at their jobs and in their homes, design thinkers become embedded in the lives of the people they are designing for.
Earlier this year, Kara Pecknold, a student at Emily Carr University of Art and Design in Vancouver, British Columbia, took an internship with a women’s cooperative in Rwanda. Her task was to develop a Web site to connect rural Rwandan weavers with the world. Pecknold soon discovered that the weavers had little or no access to computers and the Internet. Rather than ask them to maintain a Web site, she reframed the brief, broadening it to ask what services could be provided to the community to help them improve their livelihoods. Pecknold used various design thinking techniques, drawing partly from her training and partly from ideo’s Human Centered Design toolkit, to understand the women’s aspirations.
Because Pecknold didn’t speak the women’s language, she asked them to document their lives and aspirations with a camera and draw pictures that expressed what success looked like in their community. Through these activities, the women were able to see for themselves what was important and valuable, rather than having an outsider make those assumptions for them. During the project, Pecknold also provided each participant with the equivalent of a day’s wages (500 francs, or roughly $1) to see what each person did with the money. Doing this gave her further insight into the people’s lives and aspirations. Meanwhile, the women found that a mere 500 francs a day could be a significant, life-changing sum. This visualization process helped both Pecknold and the women prioritize their planning for the community.9




Ideation
The second space of the design thinking process is ideation. After spending time in the field observing and doing design research, a team goes through a process of synthesis in which they distill what they saw and heard into insights that can lead to solutions or opportunities for change. This approach helps multiply options to create choices and different insights about human behavior. These might be alternative visions of new product offerings, or choices among various ways of creating interactive experiences. By testing competing ideas against one another, the likelihood that the outcome will be bolder and more compelling increases.
As Linus Pauling, scientist and two-time Nobel Prize winner, put it, “To have a good idea you must first have lots of ideas.” 10 Truly innovative ideas challenge the status quo and stand out from the crowd—they’re creatively disruptive. They provide a wholly new solution to a problem many people didn’t know they had.
Of course, more choices mean more complexity, which can make life difficult, especially for those whose job it is to control budgets and monitor timelines. The natural tendency of most organizations is to restrict choices in favor of the obvious and the incremental. Although this tendency may be more efficient in the short run, it tends to make an organization conservative and inflexible in the long run. Divergent thinking is the route, not the obstacle, to innovation.
To achieve divergent thinking, it is important to have a diverse group of people involved in the process. Multidisciplinary people—architects who have studied psychology, artists with MBAs, or engineers with marketing experience—often demonstrate this quality. They’re people with the capacity and the disposition for collaboration across disciplines.
To operate within an interdisciplinary environment, an individual needs to have strengths in two dimensions—the “T-shaped” person. On the vertical axis, every member of the team needs to possess a depth of skill that allows him or her to make tangible contributions to the outcome. The top of the “T” is where the design thinker is made. It’s about empathy for people and for disciplines beyond one’s own. It tends to be expressed as openness, curiosity, optimism, a tendency toward learning through doing, and experimentation. (These are the same traits that we seek in our new hires at IDEO.)
Interdisciplinary teams typically move into a structured brainstorming process. Taking one provocative question at a time, the group may generate hundreds of ideas ranging from the absurd to the obvious. Each idea can be written on a Post-it note and shared with the team. Visual representations of concepts are encouraged, as this generally helps others understand complex ideas.
One rule during the brainstorming process is to defer judgment. It is important to discourage anyone taking on the often obstructive, non-generative role of devil’s advocate, as Tom Kelley explains in his book The Ten Faces of Innovation.11 Instead, participants are encouraged to come up with as many ideas as possible. This lets the group move into a process of grouping and sorting ideas. Good ideas naturally rise to the top, whereas the bad ones drop off early on. InnoCentive provides a good example of how design thinking can result in hundreds of ideas. InnoCentive has created a Web site that allows people to post solutions to challenges that are defined by InnoCentive members, a mix of nonprofits and companies. More than 175,000 people—including scientists, engineers, and designers from around the world—have posted solutions.
The Rockefeller Foundation has supported 10 social innovation challenges through InnoCentive and reports an 80 percent success rate in delivering effective solutions to the nonprofits posting challenges. 12 The open innovation approach is effective in producing lots of new ideas. The responsibility for filtering through the ideas, field-testing them, iterating, and taking them to market ultimately falls to the implementer.
An InnoCentive partnership with the Global Alliance for TB Drug Development sought a theoretical solution to simplify the current TB treatment regimen. “The process is a prime example of design thinking contributing to social innovation,” explained Dwayne Spradlin, InnoCentive’s CEO. “With the TB drug development, the winning solver was a scientist by profession, but submitted to the challenge because his mother—the sole income provider for the family—developed TB when he was 14. She had to stop working, and he took on the responsibility of working and going to school to provide for the family.” Spradlin finds that projects within the InnoCentive community often benefit from such deep and motivating connections.13




Implementation
The third space of the design thinking process is implementation, when the best ideas generated during ideation are turned into a concrete, fully conceived action plan. At the core of the implementation process is prototyping, turning ideas into actual products and services that are then tested, iterated, and refined.
Through prototyping, the design thinking process seeks to uncover unforeseen implementation challenges and unintended consequences in order to have more reliable long-term success. Prototyping is particularly important for products and services destined for the developing world, where the lack of infrastructure, retail chains, communication networks, literacy, and other essential pieces of the system often make it difficult to design new products and services.
Prototyping can validate a component of a device, the graphics on a screen, or a detail in the interaction between a blood donor and a Red Cross volunteer. The prototypes at this point may be expensive, complex, and even indistinguishable from the real thing. As the project nears completion and heads toward real-world implementation, prototypes will likely become more complete.
After the prototyping process is finished and the ultimate product or service has been created, the design team helps create a communication strategy. Storytelling, particularly through multimedia, helps communicate the solution to a diverse set of stakeholders inside and outside of the organization, particularly across language and cultural barriers.
VisionSpring, a low-cost eye care provider in India, provides a good example of how prototyping can be a critical step in implementation. VisionSpring, which had been selling reading glasses to adults, wanted to begin providing comprehensive eye care to children. VisionSpring’s design effort included everything other than the design of the glasses, from marketing “eye camps” through self-help groups to training teachers about the importance of eye care and transporting kids to the local eye care center.
Working with VisionSpring, IDEO designers prototyped the eyescreening process with a group of 15 children between the ages of 8 and 12. The designers first tried to screen a young girl’s vision through traditional tests. Immediately, though, she burst into tears—the pressure of the experience was too great and the risk of failure too high. In hopes of diff using this stressful situation, the designers asked the children’s teacher to screen the next student. Again, the child started to cry. The designers then asked the girl to screen her teacher. She took the task very seriously, while her classmates looked on enviously. Finally, the designers had the children screen each other and talk about the process. They loved playing doctor and both respected and complied with the process.
By prototyping and creating an implementation plan to pilot and scale the project, IDEO was able to design a system for the eye screenings that worked for VisionSpring’s practitioners, teachers, and children. As of September 2009, VisionSpring had conducted in India 10 eye camps for children, screened 3,000 children, transported 202 children to the local eye hospital, and provided glasses for the 69 children who needed them.
“Screening and providing glasses to kids presents many unique problems, so we turned to design thinking to provide us with an appropriate structure to develop the most appropriate marketing and distribution strategy,” explained Peter Eliassen, vice president of sales and operations at VisionSpring. Eliassen added that prototyping let VisionSpring focus on the approaches that put children at ease during the screening process. “Now that we have become a design thinking organization, we continue to use prototypes to assess the feedback and viability of new market approaches from our most important customers: our vision entrepreneurs [or salespeople] and end consumers.” 14




Systemic Problems Need Systemic Solutions
Many social enterprises already intuitively use some aspects of design thinking, but most stop short of embracing the approach as a way to move beyond today’s conventional problem solving. Certainly, there are impediments to adopting design thinking in an organization. Perhaps the approach isn’t embraced by the entire organization. Or maybe the organization resists taking a human-centered approach and fails to balance the perspectives of users, technology, and organizations.
One of the biggest impediments to adopting design thinking is simply fear of failure. The notion that there is nothing wrong with experimentation or failure, as long as they happen early and act as a source of learning, can be difficult to accept. But a vibrant design thinking culture will encourage prototyping—quick, cheap, and dirty—as part of the creative process and not just as a way of validating finished ideas.
As Yasmina Zaidman, director of knowledge and communications at Acumen Fund, put it, “The businesses we invest in require constant creativity and problem solving, so design thinking is a real success factor for serving the base of the economic pyramid.” Design thinking can lead to hundreds of ideas and, ultimately, real-world solutions that create better outcomes for organizations and the people they serve.

Friday, March 30, 2012

The Design Evolution of 11 Popular Blogs

The Design Evolution of 11 Popular Blogs


How did the design of blogs like TechCrunch or Gizmodo changed over the time? The guys from Pingdom were curious about that, and decided to profile 11 popular blogs, with pictures of their design back in the day and today.
Here is the comparison from Gizmodo:

design evolution

A couple of interesting things that I noticed:
  • Most popular blogs started with a traditional blog-like design (e.g., with categories, a tagline below the logo and so on) and migrated to a magazine-like style.
  • Most blogs started with no ads or monetization schemes at all, meaning that the goal of the authors was probably not to make money initially
  • Most of them kept their brand while changing designs (i.e. preserving colors and logos)

Thursday, March 29, 2012

Web Design Versus Web Development


Web Design Versus Web Development
The terms web designer and web developer are used interchangeably in the media and advertisements. But, they are not the same thing. Design involves what the visitor sees on your website, development involves the site’s functionality. This article explores the difference between these two disciplines.

A website contains several distinct aspects:
  • Look and feel – primarily the graphics, color scheme, navigation elements, etc.
  • Content – information, products, etc available on the site.
  • Functionality – functionality includes interactive features that the web site provides to the visitors and the required infrastructure needed to provide them.
  • Usability – the site from a visitor’s perspective and includes things like program interactions, navigation and usefulness.

Look And Feel

Look and feel includes overall appearance of the website. A Graphic designer decides on what colors and fonts to use and how to layout each of the sites pages.

The graphic designer needs to have a good appreciation for aesthetics and feeling for what combinations of colors and imagery will project the image that the website owner wants visitors to have of the site.

Content

Content is all of the text that is found on a website and includes everything from the privacy policy to a very persuasive sales letter extolling the benefits of a product and asking the visitor to part with their hard earned money and everything in between. If it is written text then it is part of the content. You need a copywriter and editor to create good content.

Functionality

Functionality includes all of the interactive aspects of a web site and includes animation. The common denominator is that programmers using the various web programming languages that work either on a web server or in a web browser create all of these functions.

Flash can be used to animate graphics. Perl, php and java are programming languages used on the web server to create sophisticated dynamic web pages. These pages can work independently but most commonly with a database to create all of the features we have come to expect from a website.

JavaScript is used in browser to create a lot of cool effects such as swapping images when a mouse moves over an image, “ticker tapes”, links changing colors, etc. JavaScript works in the user’s web browser rather than on the web server.

There are also other “backend” applications that are transparent to the visitor such as form processing, content management and other administration programs that make it possible for non-programmers to maintain some aspects of the website’s data.

All of these programs have to be integrated into the HTML code to be used on the webpage.

Usability

Usability is the website viewed from the user’s point of view and involves mostly testing things like:
  • Does the look and feel are actually portraying the proper image?
  • Is the navigation is user friendly?
  • Does the navigation lead the visitor to where the owner wants them to go?
  • Does the site load quickly?
  • Do the applications work properly?


Design Versus Development

Unfortunately, there is a lot of overlap and integration needed between web design and web development. When you toss in content creation and usability testing, it becomes a real mess.

Can a single individual do all of these things? There are some people who can do all of these things but most people only do one or two of the tasks.

Web design usually involves content creation and look and feel while web development involves creating the functionality and testing its usability.

Web designers need to be proficient with graphic design tools like Photoshop. Most also know HTML so they can implement their designs. However, using animation on the site and layout for the site’s content are also part of the web designer’s responsibility.

Many site owners provide the content for the website but a web designer needs to be able to edit and even rewrite the content if necessary. Web designers also normally do the usability testing for the navigation and site loading speed.

Web development programmers create the functionality for the website, but all of that functionality must be integrated into the HTML pages on the site. Alternatively, the HTML content could also be integrated into the program. Web developers also do usability testing on the site, at least for the functionality they create. So the programmer also needs to have some HTML knowledge as well.

In either case the web designer and web development programmer need to work together to assure that the website does everything that the site owner requested.

Bottom Line – Only large companies can afford to hire separate experts in graphic design, content creation, programming and usability testing when building a new website. In most other cases, the web designer and web development programmer are two different people who must work together to create a successful website.


Wednesday, March 28, 2012

the Future Of CSS: Embracing The Machine

the Future Of CSS: Embracing The Machine
Designers hold CSS close to their hearts. It’s just code, but it is also what makes our carefully crafted designs come to life. Thoughtful CSS is CSS that respects our designs, that is handcrafted with precision. The common conception among Web designers is that a good style sheet is created by hand, each curly bracket meticulously placed, each vendor prefix typed in manually.
But how does this tradition fit in a world where the websites and applications that we want to create are becoming increasingly complex?

Looking Back

If we look back in history, deep into the Industrial Revolution, we will see a parallel with what will happen with our handcrafted style sheets once the complexity of the products that we want to build becomes too great.
The Industrial Revolution (which took place approximately between the middles of the 18th and 19th centuries, starting in the UK) was a period of upheaval in society; several aspects of life were changing. Much of this was due to the way people produced goods: during this period, manual labor started to become mechanized. The textile industry, for example, moved from primarily human- to machine-based production, and its artisans started looking at ways to be more efficient.
C. P. R. passenger train at Donald Station, BC, about 1887

One of the many products of the Industrial Revolution. (Image: McCord Museum)
These machines that were created with efficiency in mind were initially quite primitive, and the public didn’t know what to think of them. It took us some time to adapt the way we worked with them and the way we thought of them.
Jobs that previously required human labor now didn’t require anyone; a machine could do the job cheaper and faster; employees became redundant. But the jobs in which people were being replaced by machines were mainly repetitive ones, jobs for which manual labor didn’t necessarily make for better products — at least not in any significant way.
Some argued that the output suffered in quality, that machine-made objects lacked personality, that craftsmanship was being lost, and yet production improved and evolved. We were also getting to the point that some products were getting too complex to be made by hand anymore.
This revolution shaped the world we live in today and gave us access to things that were until then too expensive or even non-existent.
Getting back to our topic, we’re seeing increasing complexity in the world of Web design and CSS. We want to create increasingly complex websites and apps — systems so complicated that they cannot be made entirely by hand.
MobileMe Calendar app

MobileMe, with its extensive functionality and comprehensive interface, is an example of a complex Web application.

The World Of Developers

Developers and programmers are already inclined towards automation. Developers instinctively avoid reinventing the wheel. They understand the need to automate production (at least some stages of it); they understand that hand-crafted code is not needed at every step of the process.
Even if you are a great front-end developer who knows JavaScript like the back of your hand, you still defer a lot of your work to jQuery or some other library. Even if you’re able to write the code yourself, the time you’d save by not doing that frees you to deal with more significant problems. The gains in writing a script from scratch are no match for the gains in being able to focus attention on problems that no machine or automated process can solve.
jQuery website

jQuery, a well-known developer’s tool.
The skills and knowledge you’ve gathered through the years are not in vain, though. This knowledge is what makes you the best person to decide whether to choose jQuery; it’s what makes you able to adjust a plugin that doesn’t quite do what you need; and it’s what makes you capable of determining the best tool for the job.

The Wrong Attitude

Web designers don’t approve of these kinds of shortcuts. This way of thinking doesn’t translate to CSS; in the world of CSS, taking these “shortcuts” is not well regarded.
We CSS authors have a list of dirty words that we avoid saying when we’re speaking with fellow Web designer friends. For example, when someone says they’ve used a CSS framework, the apology immediately follows: “It wasn’t our fault.”
Principles such as DRY (don’t repeat yourself) are not present in CSS.
DRY states that “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.” This applies not only to code but to every aspect of a product, such as design itself. When DRY principles are followed, we’re supposed to end up with products that are of higher quality and easier to maintain.
We CSS authors don’t think of the cost of maintenance or the increased complexity that duplication and cancelling out of styles add to our CSS sheets.
We usually follow something closer to WET: we enjoy typing. Why someone would want to hand-code vendor prefixes for CSS gradients is beyond my understanding, but the truth is that some people do, and they take pride in it.
CSS authors — i.e. Web designers who write CSS — don’t like the machine. We don’t think any CSS that the machine can produce will ever be as good as the one we make ourselves by hand. But what if this is not true? What if the result is as good as our own manual labor from scratch?
Other groups have had the same fears. The Luddites were workers who fiercely opposed the Industrial Revolution and progress. They said that machines were taking their jobs — which was true. But they fought, protested, became violent and eventually lost. Things would evolve whether they liked it or not.
Luddites, frame breaking

The Luddites, smashing the machine. (Image: Wikipedia)

Context Matters

It’s true that we don’t all code for the Facebooks and Yahoos of this world; your CSS’ performance might not be the most important thing to focus on in your projects. But this is why considering context matters, and this is why it’s important not to dismiss techniques and solutions because someone once told us they were wrong or dirty.
We can embrace the flexibility that some measure of automation gives us and focus our worries and energies on deeper problems. We could focus on so many things: accessibility, usability, design theory, psychology, business, economics, experimentation and even programming are all suitable candidates and are areas in which having some knowledge, even at a basic level, can greatly improve our work.
Reading list

An interesting reading list. (Image: Mike Kuniavsky)
Expanding our skill set can give us a better understanding of the products we create, the people we create them for (and their context), and how they are supposed to work behind the curtains.
Rethinking our processes might lead to better quality work. It might lead to perfecting a machine still in its infancy. If we don’t deny mechanization from coming into our work, we get the chance to shape it so that it does exactly what we want it to do.

Try This At Home

If we look around, we’ll see that several people are already trying to change the way we write our CSS, whether by introducing some kind of automation or by looking at ways of creating style sheets that don’t bypass issues such as maintainability. We can take inspiration from the work they produce in a number of interesting ways. Below are some of the most prominent examples, but feel free to add your own list in the comments section.

Frameworks: Don’t Reinvent the Wheel

As mentioned, “frameworks” are probably the dirtiest word in a CSS author’s vocabulary — or second dirtiest, after “Dreamweaver.” (Note: this article was written before the advent of Adobe’s Muse.)
Often when discussing the subject of this article, people walk away assuming that the message I am trying to get across is to use CSS frameworks. That’s not correct. But it isn’t entirely incorrect either. Let me explain.
Frameworks are an important tool in a CSS author’s repertoire. By that, I don’t mean that you should blindly use popular frameworks such as Blueprint or 960 Grid System. Sure, these frameworks have nailed some things, and we can certainly learn a lot from their flexibility and modularity, but it’s more important that you — especially if you’re on a team — adapt a framework to the needs of you, your company and your team.
Blueprint website

Blueprint, a popular CSS framework.
Perhaps you or your company works with such disparate clients and projects that a framework wouldn’t really be helpful, though. Perhaps a library in which you can collect snippets of frequently used code would be more useful. Or perhaps a starter template is what you need.
Whatever you need, more often than not you can find a way without having to reinvent the wheel from project to project. And if indeed you work with a number of other designers and developers and share CSS, then these tools will make collaboration easier, and you won’t have to adapt to the style of the person who created a particular file.
Frameworks can also be useful tools for wireframing and prototyping, especially when there are time constraints and you need to put something in front of users or stakeholders quickly.
There are differences between a framework and a patterns library, components or even a simple collection of code snippets. A framework is a system that is flexible and can be adjusted to a myriad types of layouts, creating various page templates, whereas a library constitutes smaller individual modules that don’t have to be tied to any particular overarching framework or page construction.
A pattern demonstrates how, for example, tabbed navigation should function or how to mark it up; a design component could be the exact visual representation of an instance of tabbed navigation, with its colors, shapes and fonts. This explanation of these two distinct and important concepts is very simplistic. The “Further Reading“ section at the end of this article lists some useful resources on both.
Yahoo's Design Pattern Library

The Yahoo Design Pattern Library.
A framework doesn’t have to spit out numerous unsemantic class names to every container in your markup. If you are creating your own, you are free to name those classes whatever you feel is right.
Let’s imagine you are starting to write a framework that can be shared across various development teams in your news organization. You might start with the following skeleton:
/* Resets */

/* Structure */

/* Global elements */

/* Visual media */

/* Article structure */

/* Forms */

/* Tables */

/* Reusable */
This structure is probably similar to many of your own style sheets. Let’s look at the “Article structure” section as an example of something that would probably benefit from some framework inspiration. In the project, you will probably have to accommodate several variations of templates from various departments, sub-departments, content creators, editors, etc. Rather than using classes like span-6 and pull-3, you can define a naming system that better ties into the website’s content. For example:
/* Article structure */

article {
width: 80%;
}
article.charticle { /* Charticle pages have no sidebar */
width: 100%;
}
article.listicle {
width: 70%;
}

article > .headline {
font-size: 2em;
}
article.feature > .headline {
color: #000;
}
article.breaking > .headline {
text-decoration: underline;
}

article > section {
border-bottom: 1px solid #efefef;
}

article > aside {
background: #efefef;
padding: .5em;
}

article > footer {
font-size: .9em;
}
Several things about the above CSS could be debated (I’m sure many of you have strong feelings about descendent selectors and named elements and even whether some of these classes could have been simple element selectors — to name but a few points), but none of this matters in this example. What does matter is how you can be influenced by what popular do-it-all frameworks are doing, and how you can apply that to your clean, semantic and perfectly named markup and CSS.
If you can plan for and analyze the needs of the people who create the content, then you can ensure that they have the flexibility they need to do their jobs and that you can be proud of your code. Sometimes an extra class is necessary, but if that makes everyone’s life easier, then why not, right?

Think of Others

Following what we discussed in the previous section, the fact that your CSS doesn’t live in a vacuum can be extremely useful.
Other people — and the future you — might need to come back later on to edit the style sheet that you’re creating today. Wouldn’t you want your future self to be free to go home to your spouse and kids earlier on a Friday afternoon rather than have to stay up late refactoring a CSS file that is hard to comprehend and impossible to extend?
Do yourself and others a favor by considering what you’re doing. Add comments to your CSS files for such things as the following:
Calculations

Font sizes (especially when dealing with ems) and layout measurements are great candidates for these types of comments.
h2 {
font-size: 18px;
line-height: 1.167; /* 21 (original line-height) / 18 (h2 font-size) */
}
Hacks

On the rare occasion that you use a hack, explain what you’re doing, refer to the hack by its common name, and link to an online reference that explains what you’ve just done.
aside section {
float: left;
width: 50%;
display: inline; /* fixes the double float margin bug on IE5/6. More on this bug/solution: http://www.positioniseverything.net/explorer/doubled-margin.html */
}
To-dos

Even CSS documents have “nice to haves,” so listing what you’ve been planning to do but haven’t gotten around to yet might be a good idea.
/* To-do
Change all colors to RGB format.
Sanitize reusable classes section.
*/
File structure

Summarizing what is contained in a particular file can save time when someone is looking for a certain selector.
/*  Table of contents
Resets
Structure
Links
Typography
Small screens
*/
Dependencies

Is this file being imported by some other file? Does it override something else? Explain what and how.
/* Christmas style sheet 2011

Overriding: main.css
Importing reset file: reset.css */
The fact that CSS comments are not standardized could cause a problem with all of this preparedness: everyone does them differently. In my quest for the ideal CSS formatting style, I discovered the dusty a href="http://cssdoc.net/">CSSDOC standard, which tries (or tried) to introduce some kind of sanity to the situation.
CSSDOC website

The old dusty CSSDOC website.
CSSDOC is an adaptation of Javadoc (a documentation generator that extracts comments from Java source code into HTML). It is also similar to PHPDoc, Javadoc’s adaptation for PHP. A comment that follows the CSSDOC format (a “DocBlock”) looks like the following:
/**
* Short description
*
* Long description (optional)
*
* @tags (optional)
*/
Every block starts with /** and ends with a space followed by */. Every line must start with a space followed by an asterisk. The tags may contain information such as @author, @copyright, @todo and so on.
The CSSDOC standard suggests that a CSS file should include a comment about the file itself at the top, containing meta data that is relevant to the whole file. This comment should include information such as the title of the document, a description and tags such as @project, @version, @author, @copyright and even @colordef, indicating which colors are used in the file. The file comment may be followed by any number of section comments that divide the style sheet into relevant blocks. Section comments include the tag @section:
/**
* Typography
*
* @section typography
*/
The CSSDOC documentation is not lengthy. Also, it hasn’t been maintained for a while, but I did find it interesting and have started applying it to my projects because it takes some of the guesswork and subjectivity out of comments.
Another way to make sharing documents on a team easier is to standardize the style. We all have our preferences on how to format CSS, how to name classes and IDs, address bugs, etc. Creating a style guide that recommends a way to do these things in your company will make it easier for anyone who edits the CSS to dive straight into what they need to do, rather than having to decipher someone else’s style.
This may be overkill for a team of one or two, but it can improve efficiency and save time when the team grows. In this case, consistency should have final say; personal preference is not important. If you’re the only one on a team of 12 who prefers single-line CSS, you will have to take one for the team. (Pardon me if I sound bitter; perhaps I still recall what happened on my own team…)
Here are some examples of style guidelines:
  • “Class and ID names must be lowercase.”
  • “Do not specify units for values of 0 (zero). They are unnecessary.”
When creating a style guide, include a succinct explanation for its inclusion, otherwise it will be easy for people to challenge it. The BBC has some great examples of guidelines that are relevant to CSS authors.
BBC's CSS Guidelines

An example of CSS guidelines, part of BBC’s “Future Media Standards & Guidelines” documents.

Learn About Object-Oriented CSS

Object-oriented CSS was started by front-end performance consultant Nicole Sullivan. The methodology brings modularity and flexibility to CSS by forcing you to create small flexible style sheets.
It follows two main principles. First, it states that an element should behave predictably, no matter where you place it on a page. So, a child element should behave the same independent of the parent, and parent elements shouldn’t need child elements to render correctly.
The second principle is that the rules that control the structure of elements should be separate from the rules that control their skin.
So, if you look at the pages that you need to build in a modular way and think of individual objects first and the pages second, then after creating the initial CSS you should be able to build any page layout using just the existing modules.
All of this sounds great, but object-oriented CSS does have some drawbacks.
For instance, in order for an element to be adaptable enough to be placed anywhere on the page, the name of its class should also be flexible. If you style a box and give it a class name of footer, and later on you decide to apply that style to a box in the sidebar, then the initial class name you gave it will be wrong — it’s not flexible enough. Thus, class names in style sheets that follow object-oriented CSS can sometimes be less content-driven or less semantic than we’d like.
Despite its drawbacks, object-oriented CSS has its value in certain situations. If we are working on a big website for which a small style sheet (small file size) and flexibility and maintainability are important, then following the principles of object-oriented CSS can bring huge improvements to our processes and huge savings to our company.
Once again, you don’t have to follow this methodology blindly in order to gain from its benefits.
Going back to the news company, let’s imagine you want to make a box that sits in the sidebar more prominent than other elements contained there. You might write the following CSS:
#sidebar .highlight {
background: #efefef;
border: 1px solid #000;
box-shadow: 0 0 .5em #000;
}

#sidebar .highlight > h1 {
font-weight: bold;
}
What’s so wrong with the CSS above? If you are following object-oriented CSS, then you shouldn’t restrict a style that you will probably reuse in the main content area by confining it to the #sidebar container. In our example, though, we’ll happily keep the descendent element selector in the second rule (object-oriented CSS advises against child elements being dependent on parent elements, but you can draw the line on how closely to adhere to a particular technique as you see fit, and that’s the beauty of it!).
So much more could be said about this technique. It is indeed well worth looking into, all bias aside. You will read things that you probably don’t consider good practice, but remember: context is important, and your expertise equips you to adopt the principles that will help you in your situation.

Step Into Programming

The command line is a boundary between designers and developers that we designers usually don’t want to cross. Instructions on opening the terminal can be quite intimidating for designers if they’re not familiar with it. I confess I’m guilty of steering clear of it most of the time.
But consider this: we keep talking about how we should learn and draw inspiration from the past — from print design, for example. We claim with pride to have deep knowledge of typography, color theory, layout, grids and scales. We see it as a requirement for anyone who calls themselves a professional designer.
This knowledge should be extended to encompass programming, at least at a basic level. After all, it is what powers our most precious creations.
Instead of being inspired by architecture — by its teachings, its processes and its vocabulary — why don’t we get inspired by the architect’s example, by what they have to learn? Why not be inspired by the multitude of disciplines that an architect has to know intimately in order to be a great professional?
Radiant City Model Lac Leman

How many disciplines can you spot in this model? (Image: n fiore)
Why not start now? Open Terminal. (Go on, don’t be scared. It’s only there to help.) Now type the following:
$ gem install sass
(You don’t have to write the $; it’s just there to indicate this is a Terminal command.) There, you’ve just installed Sass (which we’ll cover shortly). That didn’t hurt, did it?
If you’re working on a Sass file, you could type the following simple command to make the original Sass-formatted file automatically update the corresponding normal CSS file whenever changes are made:
$ sass --watch style.scss:style.css

The List Goes On

There are several more tools you can keep in your arsenal that can move CSS another step into the future.
Quite a few Web designers and CSS authors are becoming enamoured with CSS preprocessors such as Sass, which make it possible to extend CSS’ syntax to include, for example, variables, complex calculations and nested selectors. Not only do they enable you to use functionality not yet available in normal CSS, but you can increase efficiency by automating tasks such as updating a frequently used color on a file-wide basis, rather than having to change each instance by hand.
Sass homepage

The increasingly popular Sass.
And with all the improvements brought by CSS3, even pure and simple CSS is becoming more powerful, enabling us to create very complex layouts and animations more easily and with fewer lines of code.
The list presented here is a short one, and I’d be happy to know what techniques you apply in your own projects to make the process of writing CSS more fluid and to make your style sheets smaller and more easily maintainable and sharable.

This Is Just The Beginning

Eric Meyer says, “You can’t identify a code craftsman by whether or not they use this framework or that language. You can identify them by how they decide which framework or language to use, or not use, in a given situation.” This statement couldn’t be closer to the truth. Discussing tools without context is pointless.
Saying that something is good or bad should be done in context. By deciding that a certain technique is fundamentally flawed because someone once said so, and holding to that opinion throughout your career without ever challenging it, is not what being creative is about.
In his Critique of Pure Reason, Kant says, “Have the courage to use your own intelligence.” I would ask you to set your biases aside when when speaking about tools, techniques and processes with other designers and developers who write CSS. Don’t view different opinions as a sign of ignorance or poor craftsmanship.
Certainly, we may question certain aspects of our jobs as Web designers, and whether to be more liberal in letting automation into our processes is just one of them — but one I’m particularly interested in.
I know and work alongside very intelligent and creative programmers. These are people who understand systems so complex that my brain shrinks every time it tries to even begin to understand them. These are also people who are proud of their work, true craftsmen of their times. I find it quite interesting how these two groups (CSS authors and programmers) work on the same products but in such different ways, how they both work with code but with such contrasting values.
There is a place for carefully handwritten, handmade, perfect CSS — I take great pleasure in this myself. But there is also a place for the study and perfection of a more mechanized approach to style sheets. Both can certainly run side by side.
What are your views on this subject? Have you been trying to automate any part of your CSS writing? Do you think style sheets should always be handcrafted?

Adventures In The Third Dimension: CSS 3D Transforms

Adventures In The Third Dimension: CSS 3D Transforms


Back in 2009, the WebKit development team proposed a new extension to CSS that would allow Web page elements to be displayed and transformed on a three-dimensional plane. This proposal was called 3D Transforms, and it was soon implemented in Safari for Mac and iOS. About a year later, support followed for Chrome, and early in 2011, for Android. Outside of WebKit, however, none of the other browser makers seemed to show much enthusiasm for it, so it’s remained a fairly niche and underused feature.
That’s set to change, though, as the Firefox and Internet Explorer teams have decided to join the party by implementing 3D Transforms in pre-release versions of their browsers. So, if all goes according to plan, we’ll see them in IE 10 and a near-future version of Firefox (possibly 10 or 11, but that’s not confirmed yet), both of which are slated for release sometime this year.
That being the case, this is an ideal time to get ahead of the curve and start learning about the possibilities and potential of adding an extra dimension to your Web pages. This article aims to help you do just that, by taking you on a flying tour of the 3D Transforms syntax.
Please bear in mind that in order to see the examples in this article, you’ll need a browser that supports 3D Transforms; as I write this, that’s Safari, Chrome, IE 10 Platform Preview or Firefox Aurora.

The Third Dimension

On the Web, we’re accustomed to working in two dimensions: all elements have width and height, and we move them around the screen horizontally (left to right) and vertically (top to bottom). The move to a third dimension can be thought of as adding depth to elements, and adding movement towards and away from you (the viewer). Think about 3D films in which objects are constantly thrust out of the screen towards you in an attempt to demonstrate the possibilities of the extra depth.
To use 3D Transforms in CSS, you’ll need to know about axes (that’s the plural of axis, not the plural of axe). If you already know about working in three dimensions or remember using axes in math class at school, you can skip the next section. For everyone else, here is…

A Quick Primer On Axes

I just mentioned that on the 2-D Web, we move elements around horizontally and vertically. Each of these directions is called an axis: the horizontal line is known as the x-axis, and the vertical line is the y-axis. If we think of the top-left corner of an element as our origin (i.e. the point from which movement is measured), a movement to the left is a negative movement along the x-axis, and a move to the right is a positive movement along the x-axis. The same goes for moving an element up (negative on the y-axis) and down (positive on the y-axis).
The third dimension is known as the z-axis and, as I said, can be thought of as towards or away from you; a negative movement along the z-axis is away from you, and a positive movement is towards you.
screenshot

Showing the three axes: x (left-right), y (up-down) and z (away-towards).
If you’ve read all of this talk of axes and negative movements and you’re rubbing your eyes and blinking in disbelief and misunderstanding, don’t worry: it will all become clear when you get stuck in the code. Come back and read this again after a few examples and it should all be clear.

Transformation Functions

The various transformations are all applied with a single CSS property: transform — yes, the same property that’s used for 2-D CSS Transforms. At the moment, this property is still considered experimental, so remember to use all of the browser prefixes, like so:
div {
-moz-transform: foo;
-ms-transform: foo;
-o-transform: foo;
-webkit-transform: foo;
}
Note that Opera doesn’t currently have an implementation of 3D Transforms, but I’m including it here because work is apparently underway. For the sake of clarity, in the examples throughout this article, I’ll use only non-prefixed properties, but remember to include all of the prefixed ones in your own code.
Anyway, the transform property accepts a range of functions as values, each of which applies a different transformation. If you’ve used 2-D CSS Transforms, then you’ll already know many of these functions because they are quite similar (or, in some cases, the same). Here are all of the 3D functions:
  • matrix3d
  • perspective
  • rotateX, rotateY, rotateZ, rotate3d
  • scaleX, scaleY, scaleZ, scale3d
  • translateX, translateY, translateZ, translate3d
Now, matrix3d definitely sounds the coolest, but it’s so unbelievably complex (it takes 16 values!) that there’s no way I could cover it in this article. So, let’s put that aside and take a quick look at the others.

Rotation

To explain what this does, I’ll have to ask you to do a little mental exercise (which will come in useful later in the article, too). Imagine a sheet of card with a string running through the middle that fixes it in place. By taking the top corners in your fingers, you can move the card up and down, left and right, and forwards and backwards, pivoting around the string. This is what the rotate() function does. The individual functions rotateX(), rotateY() and rotateZ() take a deg (i.e. degree) value and move the element around its point of origin (where the string passes through it) by that much.
Have a look at our first example (a screenshot is shown below in case you don’t have access to a supported browser). Here we’ve rotated each of the elements 45° around a different axis (in order: x, y, z), so you can see the effect of each. The semi-translucent red box shows the original position of the element, and if you mouse over each, you’ll see the transformations removed (I’ve used this convention in all of the examples in this article).
screenshot

Each element is rotated 45° around a different axis: x (left), y (center) and z (right).
There is a rotate3d() function as well, but it’s too complex to explain in a brief article like this one, so we’ll skip it.

Translation

This is really just a fancy way of saying “movement.” The functions translateX(), translateY() and translateZ() each take a length value, which moves the element by that distance along the given axis. So, translateX(2em) would move the element 2 ems to the right, and translateZ(-10px) would move the element 10 pixels away from the viewer. There’s also a shorthand function, translate3d(), which takes three values in order, one for each axis, like so: translate3d(x, y, z).
In our second example, we’ve translated each of the elements by -20 pixels along a different axis (in order: x, y, z).
screenshot

Each element is translated by -20 pixels along a different axis: x (left), y (center) and z (right).
Note that translation of an element is similar to relative positioning, in that it doesn’t affect the document’s flow. The translated element will keep its position in the flow and will only appear to have moved, meaning it might cover or show through surrounding elements.

Scaling

This just means making bigger or smaller. The three functions scaleX(), scaleY() and scaleZ() each take a unitless number value, which is used as a multiplier. For scaleX() and scaleY(), this is applied directly to the width and height; for example, applying scaleY(1.5) to an element with a height of 100 pixels would transform it to 150 pixels high, and applying scaleX(0.75) to an element with a width of 100 pixels would transform it to 75 pixels wide.
The scaleZ() function behaves slightly differently. Transformed elements don’t actually have any depth to increase or decrease; what we’re doing is more like moving a 2-D object around in 3D space. Instead, the value given to scaleZ() acts as a multiplier for the translateZ() function that I explained in the last section. So, applying both translateZ(10px) and scaleZ(2) would translate an element 20 pixels along the z-axis.
There’s also a shorthand property, scale3d(), which, like translate3d(), takes three values, one for each of the individual functions: scale3d(x,y,z). So, in the following code example, the same transformation applies to both of the elements:
.e1 {
transform: scaleX(1.5) scaleY(1.5) scaleZ(0.75);
}

.e2 {
transform: scale3d(1.5,1.5,0.75);
}

Perspective

The perspective() function is quite simple, but what it actually does is quite complex. The function takes a single value, which is a length unit greater than 0 (zero). Explaining this is a little complicated; the length is like a distance between you and the object that you’re viewing (a tutorial on Eleqtriq has a more technical explanation and diagram). For our purposes, you just need to know that the lower the number, the more extreme the 3D effect will appear; any value below 200px, for example, will make the transformation appear very exaggerated, and any value of 1000px or more will seem to have no effect at all.
In our third example, we have three transformed elements, each with a different value for the perspective() function: 25px, 50px and 200px, respectively. Although the difference between the three is very discernible, it’s even clearer when you mouse over to see the transformations removed.
screenshot

Each element has a different value for the perspective() function: 25px (left), 50px (center) and 200px (right).
Note that I’ve transformed the parent elements (equally) so that we can see the degree of perspective more clearly; sometimes the difference in perspective values can be imperceptible.

Other Properties

In addition to transform, you’ll need to know about a few other important properties.

transform-style

If you’ll be applying 3D transformations to the children of an already transformed element, then you’ll need to use this property with the value preserve-3d (the alternative, and default, is flat). This means that the child elements will appear on their own planes; without it, they would appear flat in front of their parent.
Our fourth example clearly illustrates the difference; the element on the left has the flat value, and on the right, preserve-3d.
screenshot

The element on the left has a transform-style value of flat, and the one on the right has a value of preserve-3d.
Something else to note is that if you are transforming child elements, the parent must not have an overflow value of hidden; this would also force the children into appearing on the same plane.

transform-origin

As mentioned, when you apply a transformation to an element, the change is applied around a point directly in the horizontal and vertical middle — like the imaginary piece of string we saw in the earlier illustration. Using transform-origin, you can change this to any point in the element. Acceptable values are pairs of lengths, percentages or positional keywords (top, right, etc.). For example:
div {
transform-origin: right top;
}
In our fifth example, you can see the same transformations applied to two elements, each of which has a different transform-origin value.
screenshot

The element on the left has a transform-origin value of center center, and the one on the right has a value of right top.
The difference is clearly visible, but even more obvious if you pass the mouse over to see the transformation removed.

backface-visibility

Depending on which transformation functions you apply, sometimes you will move an element around until its front (or “face”) is angled away from you. When this happens, the default behavior is for the element to be shown in reverse; but if you use backface-visibility with a value of hidden, you’ll see nothing instead, not even a background color.

perspective and perspective-origin

We introduced the perspective() function earlier, but the perspective property takes the same values; the difference is that the property applies only to the children of the element that it’s used on, not the element itself.
The perspective-origin property changes the angle from which you view the element that’s being transformed. Like transform-origin, it accepts lengths, percentages or positional keywords, and the default position is the horizontal and vertical middle. The effect of changing the origin will be more pronounced the lower the perspective value is.

Conclusion

By necessity, we’ve flown through the intricacies of the 3D transformations syntax, but hopefully I’ve whetted your appetite to try it out yourself. With a certain amount of care for older browser versions, you can implement these properties in your own designs right now. If you don’t believe me, compare the list of “More adventures” on The Feed website that I built last year in a browser that supports 3D transforms and in one that doesn’t, and you’ll see what I mean.
Some of the concepts used in 3D transforms can be quite daunting, but experimentation will soon make them clear to you in practice, so get ahold of a browser that supports them and start making some cool stuff. But please, be responsible: not everything on the Web needs to be in three dimensions!

Resolution Independence With SVG



Resolution Independence With SVG


In this article, we’ll look at Scalable Vector Graphics (SVG), one of the most underused technologies in website development today.
Before diving into an example, let’s consider the state of the Web at present and where it is going. Website design has found new vigor in recent years, with the evolving technique of responsive design. And for good reason: essentially, responsive website design moves us away from the fixed-width pages we’ve grown accustomed to, replacing them with shape-shifting layouts and intelligent reflowing of content. Add to that a thoughtful content strategy and mobile-first approach, and we’re starting to offer an experience that adapts across devices and browsers to suit the user’s context.
When we look at the breadth of Web-enabled devices, responsive design is sure to provide a better user experience. Scrolling horizontally, panning and zooming the viewport have their place in user interface design, but forcing the user to do these things just to navigate a website quickly becomes tedious. Fitting the website to the viewport is about more than just layout: it’s also about resolution. In this article, I’ll demonstrate why SVG is a perfect addition to future-friendly Web development.

Introducing SVG

SVG offers a truly resolution-independent technique for presenting graphics on the Web. SVG is a vector graphics format that uses XML to define basic properties such as paths, shapes, fonts and colors, and more advanced features such as gradients, filters, scripting and animation. Create the file once and use it anywhere, at any scale and resolution.
Consider the use cases: UI and navigation icons, vector-style illustrations, patterns and repeating backgrounds. For all of these, a scalable graphic is the perfect solution from a visual standpoint, and yet fixed-resolution images are still the norm. In the example below, we’ll show you how to expand on a common development technique to take advantage of SVG.
Resolution independence with SVG

A Case Study: CSS Sprites

We all know about the CSS sprites technique. (If you don’t, then have a quick read through Sven Lennartz’ article. And Louis Lazaris points out its pros and cons.) In the example below, we’ll show how seamlessly SVG replaces normal raster images. If this technique is not for you, you can certainly imagine a whole array of similar situations in which to use SVG.
Vector icons play a big role in user interface design. Pictures express concepts with vivid clarity, whereas their textual counterparts might carry ambiguity. In UI design, where space is scarce, a simple illustrated icon could be greatly welcome.
I’ve mocked up the following example:
An icon based UI menu
I’ll be first to admit that this row of icons won’t win any design awards, but it will suffice for the sake of this article! Let’s look at the HTML:
<div class="actions">
<a class="a-share" href="#">Share</a>
<a class="a-print" href="#">Print</a>
<a class="a-tag" href="#">Tag</a>
<a class="a-delete" href="#">Delete</a>
</div>
I’ve kept the HTML to a minimum for clarity, but in practice you’d probably want to mark it up with an unordered list. And you’ll almost certainly want to replace those hashes with real URLs (even if JavaScript provides the functionality, having a fallback is nice). Let’s look at the CSS:
.actions {
display: block;
overflow: auto;
}

.actions a {
background-image: url('sprite.png');
background-repeat: no-repeat;
background-color: #ccc;
border-radius: 5px;
display: block;
float: left;
color: #444;
font-size: 16px;
font-weight: bold;
line-height: 20px;
text-decoration: none;
text-shadow: 0 -1px 2px #fff;
padding: 10px 20px 10px 40px;
margin-right: 5px;
}

.a-share { background-position: 10px 0; }
.a-print { background-position: 10px -40px; }
.a-tag { background-position: 10px -80px; }
.a-delete { background-position: 10px -120px; }
Note the fixed-pixel sizing and the PNG background, which we can see below framed in full Photoshop production glory:
A PNG sprite in Photoshop
This implementation of a CSS sprite is basic, and at today’s standard, it’s not good enough! How can we enhance this? First, let’s consider the following issues:
  1. We’ve rasterized the image at a very early stage. Even at full size, icons in which points sit between pixels, such as the one for “Print,” have blurred.
  2. If we zoom in, the image will blur or pixellate even more; there is no additional data to re-render the image at larger sizes.
  3. Everything has a fixed size, which is neither good for responsive design nor good for accessibility, because the browser’s default font size is ignored.
As you’ve probably guessed by now, we’ll show you how SVG solves these problems. But first, let’s reiterate each point thoroughly to understand the issues at large.

1. Rasterization

Devices such as modern smartphones have a very high pixel density; some already surpass the 300 pixels-per-inch (PPI) mark that is assumed to be the limit of the human eye’s ability to distinguish fine details. A pixel has no real-world equivalent in size until it sits on a screen of fixed dimension (say, 3.5 inches diagonally) and fixed resolution (say, 640 × 960 pixels). At this scale, text with a font size of 16 pixels would be incredibly small to the eye. For this reason, devices simply cannot translate 1 CSS pixel unit to 1 device pixel; instead, they double up. Thus, a 16-pixel font size actually takes over 32 pixels when rendered.
The same applies to images; but they are already rasterized, so doubling up the pixels has no benefit. In our example, each icon has been rasterized at around 25 × 25 pixels (the whole sprite being 30 × 160), so they cannot take advantage of the double pixel ratio. One solution is to use CSS media queries to detect the pixel ratio. This is already implemented in Webkit- and Gecko-based browsers.
To improve our example, we can add the following CSS declaration:
@media only screen and (-webkit-min-device-pixel-ratio: 2)  {
.actions a {
background-image: url('sprite@2x.png');
background-size: 30px 160px;
}
}
The alternate background image supplied in the code above has been saved at 60 × 320 pixels (i.e. double the original dimensions). The background-size property tells CSS to treat it smaller. Significantly, now the device has the additional data to render a better image (if capable).
This solution isn’t bad, but it doesn’t solve the problems we’ll run into in points 2 and 3 below. It also requires that we maintain multiple files of increasing size: a potential burden on bandwidth and a real hassle. For non-vector images, such as photography in JPG format, we can’t do much more than that.

2. Zooming

At their default size, our rasterized icons look acceptable, at least on low-pixel-density screens. However, should the user zoom in on the Web page, these little UI delights will degrade very quickly.
A PNG sprite zoomed in and blurred.
Zooming is a common action when users find a website too small for comfortable viewing. Or, to put it another way, websites that are designed too small are very common. There is really no “perfect” size, because almost everyone has at least some level of visual impairment, since our eyes inevitably deteriorate with age. Secondly, with the rapid increase in touchscreen devices, pinch-to-zoom has become the standard way to enlarge fixed-sized content designed for larger screens (i.e. much of the Web today).
We should develop websites in a way that minimizes the need for user input — that’s where responsive design comes in (see point 3 below) — but zooming is here to stay. There’s simply no way to provide pre-rasterized images for every level of zoom (in theory, an infinite scale). Scalable graphics are the solution, and we’ll show you how to enhance our example. But first, a related word on fixed sizing.

3. Fixed Sizes

Presenting page elements at fixed sizes forces many users to zoom, but it also disables a very useful browser feature. Users can set their preferred font size (the default in browsers is 16 pixels). By sizing everything in pixels, we override this preference. Sizing elements based on this default is much better, so that, if the text is bigger, everything adjusts to match. This essentially mimics the zooming effect but happens without the user having to manually do it on every visit. Ethan Marcotte has written a great article that explains relative font sizes.
Let’s re-implement our sprite example with a solution to these three issues.

A Scalable Implementation

Here is the HTML again. We don’t need to change anything here.
<div class="actions">
<a class="a-share" href="#">Share</a>
<a class="a-print" href="#">Print</a>
<a class="a-tag" href="#">Tag</a>
<a class="a-delete" href="#">Delete</a>
</div>
The updated CSS is where the magic happens:
body { font-size: 100%; }

.actions {
display: block;
overflow: auto;
}

.actions a {
font-size: 1em;
line-height: 1.25em;
padding: 0.625em 1.25em 0.625em 2.5em;
margin-right: 0.3125em;
border-radius: 0.3125em;
background-image: url('sprite.svg');
-webkit-background-size: 1.875em 10em;
-o-background-size: 1.875em 10em;
-moz-background-size: 1.875em 10em;
background-size: 1.875em 10em;
/* styles carried over from the original implementation */
background-repeat: no-repeat;
background-color: #ccc;
color: #444;
display: block;
float: left;
text-decoration: none;
text-shadow: 0 -1px 2px #fff;
}

.actions-em .a-share { background-position: 0.625em 0; }
.actions-em .a-print { background-position: 0.625em -2.5em; }
.actions-em .a-tag { background-position: 0.625em -5.0em; }
.actions-em .a-delete { background-position: 0.625em -7.5em; }
In this version, we’ve made the following changes:
  • The background-image is now an SVG file.
  • All sizes are based on the default of 16 pixels, or 1 em. If the user’s default is larger or smaller, then everything will scale relatively. (If you multiple each em size by 16, you’ll get the number of pixels used in our initial fixed-size example.)
  • The background-size is very important. By setting this in em units, we’re telling the browser to scale the sprite relative to everything else. You’ll notice that 1.875 × 10 em multiplied by 16 becomes 30 × 160 — the base size at which we produced the sprite in pixels.
  • The background-position of each sprited icon is also based on relative units.
Now that we’re using SVG and relative sizes, we have solved the three big issues highlighted above. A scalable graphic can be rasterized on demand to perfectly suit any device resolution and any zoom level. By using relative sizes, we can continue implementing a responsive design, minimizing as much as possible the need for the user to zoom. We’re also respecting the browser’s default font size, and enabling our design to adapt accordingly.
I actually produced the SVG sprite first and the PNG version from that. (I imported the SVG in Photoshop before exporting it as a PNG — Illustrator’s PNG export had very poor rasterization.) Below is the header in my SVG file. Notice the same 30 × 160 initial size.
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="30px" height="160px" viewBox="0 0 30 160" enable-background="new 0 0 30 160" xml:space="preserve">
You can see that the attributes for width and height are set in pixels (width="30px" height="160px") in the opening svg tag (as generated by Adobe Illustrator). This actually causes it to render early in Firefox, before the graphic has scaled to match the em sizes in background-size. Webkit-based browsers seem to scale the SVG perfectly, regardless. I’ve found that editing the SVG file to use em units in these two attributes fixes any rendering issues in Firefox.
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="30em" height="160em" viewBox="0 0 30 160" enable-background="new 0 0 30 160" xml:space="preserve">
I don’t know which browser actually implements this scaling correctly, but let it be noted that extra care is needed to ensure cross-browser perfection. Mozilla MDN has an excellent in-depth article, “Scaling of SVG Backgrounds,” which explores more practical examples. For more ideas, see Alex Walker’s article “A Farewell to CSS3 Gradients.”
Here’s a super-close screenshot showing the SVG sprite:
A close-up of a SVG sprite.
The sprite scales beautifully. (Sadly, the same can’t be said for my tacky text-shadow effect.)
It’s best to experience the joys of scalable graphics and relative sizing firsthand. I’ve uploaded a side-by-side live demo demonstrating a combination of all the techniques mentioned above.

Browser Support

At the start of this article, I said that SVG was underused. I believe that has generally been the case due to poor browser support. But things are different now! Browser support for SVG has blossomed over the last year to the point where implementing it is a viable use of development time.
According to the website When Can I Use?, support for SVG across multiple implementations is as follows (I’ve combined support for both CSS’ background-image and HTML’s img source — the most useful attributes):
  • Internet Explorer 9+
  • Firefox 4+
  • Chrome 4+
  • Safari 4+
  • Opera 9.5+
Mobile browser support is also pretty much across the board. If a workable fallback exists for older browsers, then SVG is a very viable solution.
For some of the new additions to Web standards, we can implement them safe in the knowledge that old browsers will simply ignore them and that they aren’t even required. We call this “progressive enhancement”: better browsers get a progressively better experience. SVG is slightly different, because for most practical purposes, it simply replaces other images in CSS backgrounds and HTML elements. The image format — be it SVG, PNG, JPG or GIF — is either supported or it isn’t. We can’t simply follow the practice of progressive enhancement here, because an image failing to render is not an acceptable experience.

Browser Sniffing or Feature Detection?

We could make an educated guess and say that we need to worry only about users of Internet Explorer 6 to 8. In this case, the conditional comments technique for IE-only styles enable us to re-apply a second CSS background-image of a supported format such as PNG, instead of the default SVG background.
Browsing sniffing is always a dangerous game. While Internet Explorer tends to be the main offender, we can never assume it is the only one.
The safer and highly recommended option is to detect SVG support and use it only if it’s found. I suggest using Modernizr if you need to detect multiple features. Modernizr applies a class of svg to your root html element if detected (to which you can apply SVG as a background-image). If you’re using SVG as the source of an image element in HTML, then implementation is a little harder. You’ll have to write more JavaScript to find and replace all sources once support has been established.
The problem with these methods is that the browser will download the fallback image before SVG is detected — the only exception being the conditional comments technique for IE. Users will also likely see a flash of re-styled content when the source image changes. This shouldn’t be the case for long; but at least for now, these problems may be enough to hold you off on SVG usage.

File Size

In our sprite example, the raw SVG file was 2445 bytes. The PNG version was only 1064 bytes, and the double-sized PNG for double-pixel ratio devices was 1932 bytes. On first appearance, the vector file loses on all accounts, but for larger images, the raster version more quickly escalates in size.
SVG files are also human-readable due to being in XML format. They generally comprise a very limited range of characters, which means they can be heavily Gzip-compressed when sent over HTTP. This means that the actual download size is many times smaller than the raw file — easily beyond 30%, probably a lot more. Raster image formats such as PNG and JPG are already compressed to their fullest extent.

Performance

Rendering performance is a concern with SVG, especially on mobile devices, whose hardware is limited. Raster images can be rendered pixel for pixel after decompression and de-encoding. Vector graphics need to be rasterized at a specific resolution every time they’re viewed.
SVG has consistently proved slower than Canvas as a platform for animating vector graphics; but our concern here is basic rendering, not manipulation a thousand times per second, and if that is possible, then simple rendering shouldn’t be a concern. The more intensive SVG features are things like clipping masks and filter effects. These are unnecessary for many practical purposes (like our sprite example), but, if required, the best way to check performance is by testing. A lot of Web development is supported in theory, but in practice results are far from perfect.

Alternative Methods

Hopefully you agree that SVG is extremely useful but not always the ideal solution to resolution independence. Ultimately, the trick is to avoid raster images while maintaining the scalability of visual styles. Below are a few more ideas to think about.

CSS3

You’ve probably already started combining CSS3 properties such as linear-gradient, text-shadow and box-shadow to create more complex styles. Web developer Lea Verou curates a CSS3 pattern gallery that shows off the impressive potential of gradients alone.
CSS3 gradient patterns
In his article “Mobile Web in High Resolution,” Brad Birdsall introduces a technique to maintain pixel perfection for high-resolution displays using the pixel-ratio property.
Then there are pure CSS “icons,” which Faruk Ateş rightly points out as being absolute “madness” — certainly so if you’re using CSS to create a logo! But you could argue the benefits of a small handful of very specific techniques, such as CSS triangles, as demoed by Chris Coyier.

Web Fonts

Dingbat Web fonts and look-a-like Unicode glyphs are two interesting alternatives for vector icons, both with accessibility and semantic challenges. Jon Hicks has a write-up of perhaps the best practice for this. SVG seems a more appropriate technique for icons, but both have an immediate visual impact at high resolutions — and we’ll be paying increasing attention to that in coming years.

Looking Forward

As you can see, SVG usage is very much a possibility, and browser support and performance will only improve in future. What’s important to note from this article is that we really should be building websites that are as resolution-independent as possible.
Consider the “one Web” philosophy and the vast range of devices we use to access it — there is no single user experience. The more we can do to stay device-agnostic, the better. Responsive website design addresses many of these needs and certainly provides many benefits. Using vector graphics may not be as apparent, but its little improvements really do make a difference.
With today’s level of support, many users can experience the beauty of crisp scalable graphics… or perhaps that’s the wrong way to think about it. Most users won’t say “Wow! Kudos on the vectors.” To our dismay, they probably wouldn’t even consider them (and certainly wouldn’t recognize the effort required to craft them). And that’s a good thing; each time we improve the user’s experience, we don’t necessarily need to make a song and dance about it. Letting things continue to grind away under-appreciated is OK. It’s the lack of such things that gets recognized and sniffed at. Raise the user’s expectations in visual aesthetics, and they’ll start to notice the websites that do look shoddy. If you don’t do it, others will.