Comets go around the Sun in a highly elliptical orbit.
They can spend hundreds and thousands of years out in the depths of the
solar system before they return to Sun at their perihelion. Like all orbiting
bodies, comets follow Kepler's Laws - the closer they are to the Sun, the
faster they move.
While a comet is at a great distance from the Sun,
its exists as a dirty snowball several kilmoeters across. But as it comes
closer to the Sun, the warming of its surface causes its materials to melt
and vapourise producing the comet's characteristic tail. Comet tails can
be as long as the distance between the Earth and the Sun.