There are 2 sorts of spectral lines - absorption and emission.
Let's take emission lines for a minute.
When electrons in an atom are highly energised and existing above a rest orbit and then fall down to a lower orbit, they emit a photon of energy at a particular freqency equal to the energy in the photon packet. We see it as a particular colour.
Each atom, havint difference orbit energies, therefore, gives different coloured emission lines when it is excited and the electrons drop down from higher orbits to lower ones.
Absorption Spectra are dark lines in a continous spectrum (eg that coming from the sun or other stars). The position of the dark lines corresponds to the photon energies REMOVED from the continuous spectrum when electrons steal that energy and jump from a lower energy orbit to a higher one. It is using these lines that scientists can determine what gases are present in the outer layers of stars or in nebulae that are in front of stars. The light passing through the colder gas layers has certain dark lines stolen from it and is thus like a finger print of a certain element.
Hope that helps. My brain is a bit fuzzy this late at night.