Spectroscopy is the analysis of light we observe from an object. It is a measure of the amount of light received at each wavelength. It is a powerful tool in astronomy. In fact, most of what we know in astronomy is a result of spectroscopy: it can reveal the temperature, velocity and composition of an object as well as be used to infer mass, distance and many other pieces of information. Spectroscopy is done at all wavelengths of the electromagnetic spectrum, from radio waves to gamma rays; here we will focus on optical or visible light having wavelengths between 360 and 760 nanometers (nm) - from the deep blue to the far red.
The three basic types of spectra are shown in the Fig. 1: continuous, emission line and absorption line. A continuous spectrum includes all wavelengths of light; that means it shows all the colors of the rainbow (Fig. 1a). It is produced by a dense, opaque object that is hot, either a dense gas (such as the interior of a star) or a liquid or solid (for example, a tungsten filament in a light bulb). In contrast, an emission line spectrum consists of light at only a few wavelengths, i.e., at only a few discrete colors (Fig. 1b). An emission line spectrum can be produced only by a hot, tenuous (low-density) gas. Importantly, the wavelengths of the emission lines depend on the type of gas; e.g., hydrogen gas produces different emission lines than helium. Absorption lines can be best thought of as the opposite of emission lines. While an emission line adds light of a particular wavelength, an absorption line subtracts light of a particular wavelength. Contrary to the production of emission lines, absorption lines are produced by a cool gas. Naturally there must be some light to subtract, so absorption lines can be seen only when superimposed onto a continuum spectrum. Thus, for absorption lines to be seen, cool gas must lie between the viewer and a hot source (Fig. 1c). The cool gas absorbs light from the hot source before it gets to the viewer. Here "hot" and "cool" are relative terms -- the gas must simply be cooler than the continuum source. Also note that a gas emits the same wavelengths of light that it absorbs, and absorbs the same wavelengths of light it emits.