When heated every element gives off light. When this light is decomposed using a prism it is found to be made up of a series of ``lines'', that is, the output from the prism is not a smooth spectrum of colors, but only a few of them show up. This set of colors is unique to each element and provides a unique fingerprint: if you know the color lines which make up a beam of light (and you find this out using a prism), you can determine which elements were heated up in order to produce this light.
Similarly, when you shine white light through a cold gas of a given element, the gas blocks some colors; when the ``filtered'' light is decomposed using a prism the spectrum is not full but shows a series of black lines (corresponding to the colors blocked by the gas); see Fig. 8.3. For a given element the colors blocked when cold are exactly the same as the ones emitted when hot.
The picture in Fig. 8.3 corresponds to a single element. For a realistic situation the decomposed light can be very complex indeed, containing emission and absorption lines of very many elements. An example is given in Fig. 8.4.
After the discovery of emission and absorption lines scientist came to rely heavily on the fact that each element presents a unique set of lines: it is its inimitable signature. In fact, when observing the lines from the solar light, it was found that some, which are very noticeable, did not correspond to any known element. Using this observation it was then predicted that a new element existed whose absorption lines corresponded to the ones observed in sunlight. This element was later isolated on Earth, it is called Helium (from helios: sun).
In following this line of argument one has to be very careful that the lines are not produced by any other element. This is complicated by the fact that some lines are observable only under extreme circumstances and one has to take them into consideration as well. For example, after the success of the discovery of Helium, another set of lines (not so prominent) was isolated and associated with yet another element, ``coronium''. It was later shown that the coronium lines were in fact iron lines, which are clearly observable only in the extreme conditions present in the sun (one can also see them in the laboratory, it's just hard to do so).