Understanding CSS Animations in Electronic mail: Transitions and Keyframe Animations


Electronic mail entrepreneurs and designers are consistently searching for methods to set their campaigns aside within the inbox. From design to dynamic content material and promotions to personalization, entrepreneurs are testing out completely different methods to pique subscriber curiosity and improve engagement.

One of many extra frequent methods to boost emails is by including animation and movement to a marketing campaign. Movement helps draw the attention to particular content material and suck the person into that content material. Whereas movement in electronic mail has historically been achieved via animated GIFs, CSS animations can generally be a simpler method.

CSS animations are animations which are constructed utilizing code—particularly HTML and CSS. Utilizing a handful of CSS properties, electronic mail entrepreneurs can manipulate the HTML of their campaigns and create the same sense of movement as when utilizing animated GIFs. Maybe extra importantly, they will create extra interactive and interesting campaigns, too.

On this information, we’ll discover the professionals and cons of utilizing CSS animations in electronic mail, in addition to the code that powers CSS animations.

Why use CSS animations?

CSS animations have been round for years, however are solely lately seeing wider use each within the internet and electronic mail industries. For a very long time, animation on the net was created both in a proprietary instrument like Adobe Flash or Microsoft Silverlight or as an animated GIF—a picture format that permits for frame-based animations. Since electronic mail shoppers by no means actually supported using Flash or Silverlight within the inbox, electronic mail entrepreneurs have been left utilizing animated GIFs in the event that they wished motion of their campaigns.

That is largely nonetheless the case. In response to our 2018 State of Electronic mail Survey, 78% of manufacturers use animated GIFs of their campaigns, whereas solely 30% use CSS animations.

Supply: Litmus’ 2018 State of Electronic mail Survey of three,000 advertising and marketing professionals.

Though animated GIFs have wider assist, CSS animations have an a variety of benefits when used correctly.

One of many largest advantages of CSS animations is that they create quicker loading emails in comparison with utilizing an animated GIF. As an increasing number of emails are learn on cell, electronic mail entrepreneurs have to deal with subscribers utilizing restricted bandwidth and small knowledge plans. Animated GIFs are typically on the heavier facet relating to file weights, and might be gradual to load and show on cell units. CSS animations, nevertheless, are code. Being text-based, they’re fast to load and play easily on most fashionable units. They’re a good way to create a fascinating person expertise with out chopping into customers’ costly knowledge plans.

Maybe an important good thing about utilizing CSS animations is that they help you create extra interactive experiences for subscribers. Since CSS animations might be tied to particular person behaviors—like hovering over a CTA or tapping on a component in an electronic mail—they can be utilized to cycle via content material and completely different visible states of a marketing campaign.

Though CSS animations use only some core CSS properties, these properties can be utilized to create extraordinarily highly effective and spectacular electronic mail campaigns.

Two Varieties of Animation

On the coronary heart of CSS animations are two key ideas: transitions and keyframe animations. Utilizing these two ideas, you may create every part from a easy hover impact on buttons to extra complicated animations which are triggered in an interactive electronic mail.


CSS transitions do precisely what the title implies: They transition a component from one state to a different, animating that aspect within the course of. One of the best ways to know a CSS transition is by taking a look at an instance.

Let’s say we’ve a call-to-action button with a easy hover impact that switches between two background colours.

See the Pen CSS Animations in Electronic mail: Instance 1 by Jason Rodriguez (@rodriguezcommaj) on CodePen.


You may see within the CSS that there are two states to the button. The traditional one and the :hover state that swaps these background colours. By making use of the CSS transition property to the default button state, we are able to add a pleasant transitional animation between the 2 states:

See the Pen CSS Animations in Electronic mail: Instance 2 by Jason Rodriguez (@rodriguezcommaj) on CodePen.


The transition property takes a couple of values together with the property, timing, and easing operate properties to find out how the animation performs. In our instance, the transition property is about to all, which can animate each CSS property on that aspect. The timing is about to zero.6s (seconds) in order that it doesn’t take too lengthy and really feel sluggish, and the easing operate is about to ease, which can—naturally—ease the animation out and in.

What’s cool about CSS transitions is that they are often mixed with different CSS properties to create some actually fascinating results. If we wished to attract much more consideration to our CTA, we may add two extra CSS properties—box-shadow and remodel—to present the button a 3D look.

See the Pen CSS Animations in Electronic mail: Instance three by Jason Rodriguez (@rodriguezcommaj) on CodePen.


The fantastic thing about CSS transitions is that they’re so easy. With only one line of code, you may superbly animated between two states. And, when mixed with all the different cool stuff CSS can do today, you may create electronic mail magic.

Try a few of these assets to study extra about what might be completed with CSS transitions:

Keyframe Animations

Did you ever make a flipbook out of a pad of Submit-It Notes while you have been a child? Bear in mind how flipping via your drawings allow you to create your individual little film? CSS keyframe animations work in the identical method. As an alternative of drawing every particular person body, you need to use code to arrange the person “pages” or “frames” for an animation and depend on CSS to animated between these frames. Keyframe animations are a bit extra complicated than transitions, however that complexity comes with extra energy, too.

Once more, one of the simplest ways to know keyframe animations is by taking a look at an instance.

See the Pen CSS Animations in Electronic mail: Instance four by Jason Rodriguez (@rodriguezcommaj) on CodePen.


Within the above instance, I’ve a mock electronic mail that may must be scrolled on a cell machine. To encourage that scrolling, I added an arrow that makes use of keyframe animations to softly bounce up and down. Whereas the identical factor may very well be completed with an animated GIF, it was a lot faster to make use of code to construct out that movement.

Step one in constructing a CSS keyframe animation is to outline the animation with the @keyframes rule. You want to add a reputation with which to later reference that animation. On this case, I known as it bobbing, since that’s precisely what the arrow is doing.

Inside that CSS rule, I arrange two frames within the animation: from and to. The primary—from—is the preliminary state of the animation and makes use of the remodel property with none actual values to mark the start location of the arrow. The second body—to—is the ending location. Once more, utilizing remodel, I moved the placement of the arrow 60 pixels decrease.

You may construct extra complicated frame-based animations by swapping out the from and to key phrases with percentages to indicate particular person frames. For instance, if I wished to have an animation with 5 frames as an alternative of two, I may add in CSS properties at 20%, 40%, 60%, 80%, and 100%, with every set of properties wrapped in curly braces like within the code above.

Upon getting your keyframes arrange, you want to provoke the animation. We do that by concentrating on the HTML aspect we need to animate and including the animation property on that aspect. Within the instance above, I goal a div with the category animate. Throughout the animation property, you may embody plenty of values to outline the habits of your animation. These embody:

  • animation-delay
  • animation-direction
  • animation-duration
  • animation-fill-mode
  • animation-iteration-count
  • animation-name
  • animation-play-state
  • animation-timing-function

Not all of them are mandatory in each CSS animation you create. In our instance, I simply use length, timing operate, iteration depend, and route. The length is counted in seconds (1s) and the timing operate is about to ease. Since I would like the animation to loop, I set the iteration depend to infinite after which reverse the route upon completion.

There’s lots that may go into CSS keyframe animation, so I’d recommend digging into the Mozilla Developer Community’s wonderful documentation on the topic.

Whereas it is a primary instance of CSS keyframe animations, it ought to hopefully offer you an concept of what’s potential in electronic mail while you need to transfer past animated GIFs.


Though CSS animations have many advantages, the foremost draw back of utilizing them is restricted assist in electronic mail shoppers.

It also needs to be famous that assist comes with a couple of gotchas, which Justin Khoo has famous within the “Shopper Particular Quirks” part of his wonderful Kinetic Electronic mail CSS Assist web page.

What’s nice about CSS animations, although, is that even after they’re not supported, they fall again gracefully. In electronic mail shoppers with out assist, the HTML components nonetheless show, they simply don’t animate. Your electronic mail continues to be useful and might be simply loved by subscribers.

Animation Inspiration

There are lots of people within the electronic mail trade placing CSS animations to make use of, together with Litmus! To get a greater concept of what’s potential utilizing CSS animations, we’ve rounded up a few of our favourite campaigns:

Though a few of these emails are extra experimental than the everyday electronic mail advertising and marketing marketing campaign, they embody concepts that may be integrated to spice up engagement for practically any trade. All it takes is slightly apply, testing, and a way of journey.

Check Your Animations with Litmus Builder

Excited to start out utilizing CSS animations in your individual campaigns? Begin creating your subsequent electronic mail with Litmus Builder—the one code editor designed for electronic mail designers by electronic mail designers. Rapidly code and preview your emails in 90+ completely different electronic mail shoppers, save your animations with Snippets and Partials, and add your marketing campaign on to your electronic mail service supplier with ESP Syncing.

Begin constructing at the moment →

The submit Understanding CSS Animations in Electronic mail: Transitions and Keyframe Animations appeared first on Litmus Software program, Inc..

Supply hyperlink


Please enter your comment!
Please enter your name here