In the outer solar system a comet is an icy body (not necessarily in the sense of water ice, but a variety of frozen out gases like methane as well as dust), but if its (highly elliptical) orbit takes it into the inner solar system solar radiation will vaporize some of the ice. This gas is what forms the comet tails that most people are familiar with.
In the above picture (of Comet Hale-Bopp) you can see this gas as white material trailing the comet and will trace out the same orbit as the comet, though flung out a bit as time goes on. You will also notice, however, a fairly distinct stream of blue gas. This is the bit of information that I don’t think many people know about, namely that a comet has two tails. The first is called the dust tail, formed of particles that have broken off of the comet due to heating. Some of the material will be ionized however, and this is what constitutes the other tail, or gas tail. Unlike the dust tail which follows the orbital track of the comet, the gas trail always points at right angle away from where the Sun is with respect to the comet, since the ionized gas is carried by the charged solar wind (since the solar wind is itself composed of charged particles ejected from the sun).
Summary: Solar radiation causes uncharged flecks to break off of the comet and form a trailing dust trail and also causes vaporization that emits charged gas which points directly away from the Sun, forming a gas tail.