Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Why and when to use CSS animations


From:

CSS: Animations

with Val Head

Video: Why and when to use CSS animations

With the addition of animation, CSS has joined the list of possible ways we can create motion using web technologies. In this tutorial, we'll look at how to decide which of our options to use. Are CSS animations right for your current project? The answer to that question is rarely as black and white as we'd like it to be. But I'll give you some factors to consider to help you answer that all important question. Let's start by looking at the main strength of CSS animation first. Tests have shown that CSS animations can render faster and be less memory intensive than a JavaScript equivalent.
Expand all | Collapse all
  1. 4m 47s
    1. Welcome
      41s
    2. What you should know before watching this course
      58s
    3. Vendor prefixes and browser support
      2m 11s
    4. Using the exercise files
      57s
  2. 28m 16s
    1. Animation basics
      6m 32s
    2. Exploring animation delay and the fill-mode property
      6m 6s
    3. Working with animation direction
      4m 49s
    4. Understanding easing
      8m 47s
    5. Challenge: Adding keyframes to our animation
      49s
    6. Solution: Adding keyframes to our animation
      1m 13s
  3. 47m 37s
    1. Creating a seamlessly looping animation
      6m 27s
    2. Animating an element into place
      5m 43s
    3. Playing and pausing an animation on hover
      6m 20s
    4. Animating 3D transforms
      8m 6s
    5. Preparing a sprite image for animation
      4m 55s
    6. Animating the sprite image with steps
      5m 34s
    7. Chaining multiple animations on one element
      8m 2s
    8. Challenge: Adding a third animation to the chain
      46s
    9. Solution: Adding a third animation to the chain
      1m 44s
  4. 19m 54s
    1. A preview of what we'll be creating
      1m 10s
    2. Setting up the HTML structure
      1m 48s
    3. Adding the header animation
      5m 57s
    4. Animating the data
      6m 8s
    5. Adding interactivity with JavaScript
      4m 51s
  5. 12m 44s
    1. Why and when to use CSS animations
      4m 50s
    2. Organizing animation code for semantics and fallbacks
      4m 51s
    3. Crafting effective animations
      3m 3s
  6. 3m 0s
    1. Helpful online tools for creating and building animations
      3m 0s
  7. 34s
    1. Next steps
      34s

please wait ...
Watch the Online Video Course CSS: Animations
1h 56m Intermediate Feb 14, 2013

Viewers: in countries Watching now:

This course presents a short series of CSS animation techniques, such as looping, playing, and pausing, and puts them together in a small project: an animated infographic. Author Val Head also addresses using CSS preprocessors, adding transitions, handling vendor prefixes, and understanding the best uses for CSS animations. Plus, discover how to measure the performance and current level of browser support for CSS animations and how we can expect the technology to change.

Topics include:
  • Understanding delay and fill-mode
  • Dictating an animation's direction
  • Using easing
  • Adding keyframes
  • Looping an animation
  • Chaining multiple animations on one element
  • Setting up the HTML structure
  • Adding interactivity with JavaScript
Subject:
Web
Software:
CSS
Author:
Val Head

Why and when to use CSS animations

With the addition of animation, CSS has joined the list of possible ways we can create motion using web technologies. In this tutorial, we'll look at how to decide which of our options to use. Are CSS animations right for your current project? The answer to that question is rarely as black and white as we'd like it to be. But I'll give you some factors to consider to help you answer that all important question. Let's start by looking at the main strength of CSS animation first. Tests have shown that CSS animations can render faster and be less memory intensive than a JavaScript equivalent.

This happens because the bulk of the work for rendering a CSS animation is handled by the browser internally, which allows for some increased efficiency. If you're animating with transforms, as we often have throughout this course, your CSS animations can also benefit from hardware acceleration. This means they'll be rendered on a different internal layer by the browser. If you're interested in reading more about CSS animation performance versus jQuery performance, I'd recommend checking out this article by Chris Mills on the Opera Dev site. He goes into a lot more detail and how he tested this and the results that he got.

Personally, the biggest advantage I see for CSS animations is how easily available they are. There's no plug-ins or libraries to install before you can start working with motion. You can just jump right in with the technology you're already using, HTML and CSS. This greatly lowers the barrier to adding compelling bits of motion to your project. This also makes it easy to add just a little bit of motion without having to go all out crazy. These are some compelling advantages for sure, but how do you decide if CSS animations are appropriate for your current project, especially when it comes to client work? There are two main factors I take into consideration when deciding if CSS animations are right for a particular project.

The first is how critical the content included in or conveyed by the animation is? The second is which browsers the audiences for this project are most likely to be using? Let's talk about each of this in just a little more detail. The best test for deciding if your animation is critical is to ask yourself if the page or screen in question will still make sense without the animation. For example, an animation that demonstrates a particular software feature would be critical to someone's understanding. Whereas, an animation designed to call a little bit of extra attention to a button on the page may not be so critical.

Next, consider the browsers that will likely be used by your audience. The easiest way to do this is to look at the browser statistics for the current site and compare that to a site like caniuse.com that charts browser support for CSS animations. If there are a large percentage of visitors using older browsers, like IE9, for example, which we see here has 0 support for animations, there is a good chance that a lot of your visitors won't see your CSS animations due to lack of browser support. If your animations are critical, using CSS animations in this case would not be the best idea.

If your animations are critical, and there's a large percentage of less capable or older browsers in your audience, your audience might be better served by a jQuery based animation or another JavaScript library with strong older browser support. However, if your animations don't include critical content, it's a different story. Using CSS animations in this case will provide a slightly richer experience for those with more capable modern browsers. Anyone using an older or less capable browser like IE9 won't really be any worse off.

This fills with the concept of progressive enhancement, providing an enhanced experience for more capable browsers, but making sure that the less capable browsers still have all the necessary and required content. If you'd like to learn more about the concept of progressive enhancement, I'd highly recommend this article on A List Apart, by Aaron Gustafson. He goes into a lot of detail of the concept behind it and uses a lot of really great metaphors and illustrations. One last consideration when deciding whether or not to use CSS animations in a project is mobile browsers.

The range of mobile browsers out there today makes for a very interesting landscape. Many of these mobile browsers, mobile safari for example, handles CSS animations nearly perfectly. But there are some very interesting quirks out there in mobile browsers, which maybe only partially supports CSS animations, and that happens a lot especially in the Android Market. It's impossible to go over every possible device and browser combination here, but if you happened to be targeting a specific device or browser version with your project, it's best to start testing early and often to be sure it has the support you need.

If I could sum up all my advice on this topic in just one thing, I would say to always consider your audience first and go with your gut on what makes the most sense for them. There are plenty of opportunities to use CSS animations to enhance the interactions of your site or web app and the opportunities are only going to increase in a not so distant future. As long as you're sure to consider the goals of your audience, you'll be off to a great start adding CSS animations to your work.

There are currently no FAQs about CSS: Animations.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CSS: Animations.

Return to your organization's learning portal to continue training, or close this page.


OK

Upgrade to View Courses Offline

login

With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts.
lynda.com provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now
 

A trusted source for knowledge.

 

We provide training to more than 4 million people, and our members tell us that lynda.com helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.