Most comets are made of frozen ice and dust particles. Comets spend the majority of their time far from the Sun. Because of their long, highly elliptical orbits ,the long period comets will eventually approach the Sun, increasing in velocity rapidly as they do. The ice and dust begin to melt forming a "cloud" around the nucleus of the comet. This cloud is pushed away from the direction of the Sun by two forces, the solar wind - particles of charged gas streaming out from the Sun, and light pressure - the force generated from packets of energy known as quanta or photons that is a property of light energy.
This actually generates two tails: an ion tail of comet gases caused by the solar wind and a slightly curved dust tail generated by the photons striking the comet's suspended dust particles.