A spectral line is the way scientists can tell one element from another by looking at color.
The colors of the rainbow change
In order to understand spectral lines, color has to be understood. In a rainbow, the colors of light go from purple to red. Several hundred years ago, the famous scientist Isaac Newton did an experiment where he showed that even white light from the Sun was made up of all the colors of the rainbow. When other scientists following him looked at this rainbow very closely, they noticed that there were dark lines breaking up the rainbow, where certain shades of colors should be. These lines were very small, but could be seen when the rainbow got stretched out very far. They investigated this further, and discovered that certain chemical elements, like the hydrogen and helium that make up the Sun, absorbed certain frequencies of light where those colors should be, like a sponge absorbs water, but does not absorb chalk.
Elemental fingerprints change
Soon, scientists discovered that when they heated other chemical elements, like calcium and oxygen, so hot that they shined with a white light, they found similar lines, but in different places. No two chemical elements had these lines in exactly the same places along the rainbow, and they also soon discovered that could be used to be able to tell what stars were made up of in the Universe. The lines that a particular element produces are called the emission spectrum of that element.
The reason the chemical elements can do this is because of the number and places of electrons orbiting around the center of each atom of each chemical element. These electrons, when light hits them, absorb a specific wavelength, or color of light, and what color they absorb depend on their position around the atom. Since each chemical element has a certain number of electrons, each chemical element has this unique set of spectral lines.
Red shift change
Since each set of spectral lines was unique, scientists could also be able to use this in a technique called red shift. Red shift is a method astronomers use, after they know what a star is made of, to tell how fast an object far away in the Universe is moving. It also tells them how far away it is.