As a comet nears the Sun its frozen gases start to melt. This releases vapour and dust and the comet grows a "tail". The nearer the comet is to the Sun, the longer the comet's tail becomes.
Note that the tail or coma* of a comet is always "blown" away from the Sun. This is the effect of the Solar Wind - a continuous stream of highly-charged particles emitted by the Sun.