What causes comets to have tails?

Flexi Says:
Comet tails form as the comet flies close to the Sun and the outer layers of ice melt and form a glowing coma. Particles streaming from the Sun push this gas and dust into a long tail. The tail always points away from the Sun. The coma is bright because it reflects light from the Sun (Figure here). Comets appear for only a short time when they are near the Sun. They seem to disappear as they move back to the outer solar system.