Spectroscopy is the analysis of light spectra and the way in which light interacts with matter. When light is analyzed it is commonly separated into its component colors. The light source is directed on a slit and the "beam" of light is separated using a prism or grating.
The reason that the images are lines is that the light from the lamp is focused on a narrow slit. The illustration shows the separation of a light beam into its component colors.
Use simulation