The comets that visit the Sun occasionally from the furthest limits of the solar system differ from the asteroids in having a greater quantity of water ice and frozen gases mixed with their rock. They formed at the birth of the Solar System in the cooler regions beyond Mars, where ices could survive. Encounters with the giant planets flung them into vast, stretched outer orbits that carried them to the limits of the Sun’s gravitational field.
As the comet nucleus approaches the Sun these’ ices’ warms up, turns into gas and blow rock and dust into space. A halo of gas and dust, called the coma, forms around the nucleus. A long straight tail of gas, glowing blue, is driven off by radiation from the Sun, and a yellowish dust tail also streams from the nucleus. The tails point away from the Sun all the time that the comet sweeps past, though the more sluggish dust tail is curved because it lags slightly.
Most observed comets have been seen only once in human history, because they take millions of years to complete an orbit. And often in that time they are deflected by one of the giant planets into a new orbit that keeps them away. But a steady supply of new comets is sent in towards the inner Solar System by gravitational disturbance in the comet cloud that envelops the sun at a distance of several light years. A few are closer in, and reappears at intervals measured in years. They wear out a little at each pass, and ultimately fade or break up.