21joanna12 said:
I would think that both the chromosphere and corona would cause spectral lines, but at the same time I have read that both of these layers have a higher temperature than the photosphere, and spectral lines can only be formed if the light passes through a cooler gas...
There is no requirement for the gas to be cooler, any time a continuum passes through low density gas, spectral lines will be superimposed on that continuum because the low density gas only interacts with the light at certain wavelengths. There are many ways of getting either absorption or emission lines, some involving temperature, some involving scattering, and some involving geometric effects, and the Sun involves a lot of these phenomena. But the most common one is the photospheric absorption line-- that's the one that involves light passing through cooler gas, because the temperature in the photosphere drops as you go out from the center.
Would the photosphere be producing its own spectral lines too?
Yes, those are mostly the lines you see. The "photosphere" is not really all one place, it's not an infinitely thin spherical shell. The photosphere is best defined as simply the gas that is visible to us and is undergoing an equilibrium between the rate it absorbs light from below, and the rate it emits light into deep space. The fact that light is diffusing through it causes its temperature to fall as you go out, and that is what causes those absorption lines, but there are also other kinds of lines in other parts of the solar spectrum-- like chromospheric and coronal lines.
Indeed, the element named for the Sun, helium, was first discovered by looking at emission from ionized helium in the solar corona during a solar eclipse. That light would be seen in emission simply because you are waiting for the Moon to block out the solar continuum, and you see the line from outside the disk of the Sun against no continuum background. Otherwise it would be swamped by the brightness of the Sun. I believe we can now also see absorption lines from neutral helium in the photosphere, and if so, that provides an example of both types of lines from the same element in the Sun in different situations.