A comet is an icy small Solar System body that, when passing close to the Sun, heats up and begins to outgas, displaying a coma (atmosphere) and a tail. These phenomena are due to the effects of solar radiation and the solar wind upon the nucleus of the comet. Comet nuclei range from a few hundred metres to tens of kilometres across and are composed of loose collections of ice, dust, and small rocky particles. The coma and tail are much larger and, if sufficiently bright, may be seen from the Earth without the aid of a telescope.

As a comet approaches the inner Solar System, solar radiation causes the volatile materials within the comet to vaporize and stream out of the nucleus, carrying dust away with them.

The tail, made of gases, always points directly away from the Sun because this gas is more strongly affected by the solar wind than is dust, following magnetic field lines rather than an orbital trajectory.

More Info: en.wikipedia.org