There are only two file formats which are truly universal for publishing on the World Wide Web: GIF and JPEG. Of these two, only GIF supports animation. Here's an example of an animated GIF:
An animated GIF is, more or less, just a bunch of static GIFs which are bundled together in a single file. The static images are played in succession to create the illusion of movement. Here are just a few of the 51 static images which are a part of the above animation:
This technique is called frame-by-frame animation, because each static image (or frame) must be created separately.
Animated GIFs are ubiquitous, but they do have some drawbacks. Because they use frame-by-frame animation, they are somewhat difficult to create. GIFs are also pixel-based, so that if we enlarge the image, we can see the individual square elements (or pixels) that compose it.
There are other file formats for putting animation on the Web. These formats allow you to be more creative and efficient. Web browsers must have special software installed in order to view animations in these formats, but this software is free and fairly ubiquitous. If you have a recent version of a major Web browser, chances are you may already have what you need.
The most notable formats for animation are Shockwave and Quicktime.