Halley's comet is arguably the most famous comet. It is a "periodic" comet and returns to Earth's vicinity about every 75 years, making it possible for a human to see it twice in his or her lifetime.
These comets are remnants left over from the formation of stars and planets, billions of years ago and are referred to as “dirty snowballs”. Comets orbit the sun, but most are believed to inhabit in an area known as the Oort Cloud, far beyond the orbit of Pluto. A comet occasionally streaks through the inner solar system and when a comet's orbit brings it close to the sun, it heats up and spews dust and gases into a giant glowing head larger than most planets.
The dust and gases form a tail that stretches away from the Sun. If a comet is traveling towards the Sun then the tail will follow behind, but if the comet is traveling away from the Sun the tail will be in front of the comet. The comet begins to melt leaving behind magnificent tails when they approach warmer inner Solar System close to the Sun. As the comet passes within six AUs of the Sun, the ice begins to go directly from the solid to the gas state and when the ice sublimes, the gas and dust particles flow away from the sun to form the comet's tail. (AU, The astronomical unit, is the average distance from the Earth to the Sun and is about 93 million miles or 150 million km)
Comets can have short period orbits (less than 200 years such as Halley's comet ) or long period orbits (greater than 200 years such as comet Hale–Bopp). Some comets, however may move out of the solar system and roam freely in the interstellar space.