Comets are cosmic snowballs of frozen gases, rock and dust roughly the size of a small town. When a comet's orbit brings it close to the Sun, it heats up and spews dust and gases into a giant glowing head larger than most planets. The dust and gases form a tail that stretches away from the Sun for millions of kilometers.
The center of a comet, the nucleus, is very small compared to the rest of the comet, and is usually only a few kilometers in diameter. It is the part of the comet that is always there, at least as long as the comet exists. The nucleus is composed of rocks and ices. As comets age, they lose their ices, and a comet is considered "dead" when it no longer has any ice, for it can no longer sport any feature other than its nucleus.
The other parts of a comet are only in existence when the comet approaches the Sun—usually once it is closer to the Sun than Jupiter (5.2 A.U.). The Sun's heat melts some of the ice in the nucleus to form a huge glowing "head," the coma. The coma can grow to immense proportions, sometimes becoming over 10,000 km (6,700 miles) across. Because the ices of the comet are made of various molecules (such as carbon, nitrogen, oxygen, and water), and the different molecules weigh different amounts, some can escape the nucleus' weak gravity more easily. Therefore, another minor feature of the coma is the Hydrogen Cloud, which forms the outer part of the coma.
Finally, the part of a comet that is most well-known is the tail. Most comets usually have two tails, and usually one is much brighter than the other. The tails form as a result of the Sun's solar wind—the stream of charged particles that emanate from the Sun. The solar wind dislodges gas and dust from the comet and forces the material into very narrow (relative to their length) tails. The tails always point away from the Sun, which is sometimes counter-intuitive. This is because even when the comet is traveling away from the Sun, the tail faces away, so the comet is, in effect, following its tail.
The gas and dust form separate tails due to the charge of their constituents. The dust is not highly charged, and so forms a bent tail that slightly lags behind pointing directly away from the Sun; its color is yellow because it reflects the light of the yellow Sun. The gas tail is much more highly charged, and so the solar wind acts to funnel it much more effectively than it does the dust cloud; its color is blue due to molecules that make it up.
The tails can be several million miles long each, and the longest have been observed to be over one A.U. (over 93 million miles long). Due to the nature of how the tails form—material being blown off of the comet—the tails are how comets loose the bulk of their mass. The material usually dissipates after several hundred years, but before that happens, the material usually will continue in the orbit of the comet. If the Earth plows through this, we see a meteor shower.