Hi Jeff,
We can see the lines in spectral by spreading the light from the Sun into its different colors. This is what happens in a rainbow, but with spectrographs we can do a lot better. Here is an example - the colors are wrapped around or it would be too long to show. You can see the dark lines.
We also look in other ranges of light - colors people can't see, light the ultra-violet. There we can often see lines that are brighter than the light around them. That is the range of the spectra that I study using instruments on the SOHO spacecraft.
One of the ways we know what elements (like hydrogen, helium, oxygen, etc.) the lines come from is to compare them to spectra we can produce in laboratories on Earth. Also, we can use our knowledge of atomic physics to calculate where the lines from an atom or element ought to be.
There are stars with spectra similar to our sun. The ones most similar to the Sun are called G type stars (the Sun is a G2 star). In fact, the main way stars are catagoried is by their spectra, using spectral lines.
cheers,
Terry