The correct response is: They were absorbed when leaving the sun.
When the sunlight passes through the layers of the sun's atmosphere, certain colors (wavelengths) are absorbed by gases and elements present there, resulting in the missing colors (dark lines) observed in the spectrum. This phenomenon is known as absorption lines in the spectrum.