As a comet approaches the Sun, it is heated, releasing gas and dust into a temporary atmosphere (called the coma) around the nucleus of the comet. It is the interaction of photons of sunlight and the solar wind with this coma that produces the long cometary tails we normally associate with this type of celestial object.
Comets typically show 2 main tails. The gas tail consists of charged particles swept along by magnetic fields embedded in the solar wind. The dust tail is composed, not surprisingly, of dust particles, released from the nucleus by escaping gases and pushed out into a curved tail by radiation pressure. Occasionally a third tail is also detected. This neutral tail consists of neutral sodium atoms thought to be released by dust particles in both the coma and the dust tail.
All three tails point away from the Sun, which means that after perihelion, they actually 'lead' the comet in its orbit.