Comets originate in the 'Oort Cloud' - a cloud of ice and debris surrounding the solar system far out beyond the orbits of the planets. If one of these pieces of debris manages to succumb to the sun's gravitaional pull rather than hat of the surrounding bits of debris, it will begin an orbital path round the sun, in an elongated elipse (like a cigar-shape). This is what we call a comet. As the comet is in orbit round the sun, it will reappear near earth at intervals.Some comets have a relatively short reappearance time - the most famous being Halley's Comet at 76 years. Some comets take 3000 years to reappear or even more. When it approaches the sun at distance it is simply a block of ice and rock. However, when it gets near the sun, the solar wind ( a stream of radiation from the sun) and radiation melt the surface of the comet so that a tail emerges. (actually two tails form - but the reasons need not be explored here). The characteristic tail is what we see when looking at a comet. The tail always faces away from the sun (not behind the comet in the direction of travel, which is commonly, but wrongly believed) because of the solar wind pushing away debris in a direction opposite to the sun. After its orbit the comet will return to the Oort cloud as its tail disappears (as the solar wind has less effect) to begin its journey round the sun again. After several journeys, the comet will lose more and more material (that forms the tail) because of the Solar wind. There will come a time when the comet eventually dies out like an icecube melting on a hotplate.