The Sun (as well as other stars) is hot enough internally that "free" electrons produce a continuous ("rainbow")
spectrum. As that radiation passes through the outer layers of the Sun, some wavelengths are absorbed by atoms and ions in the stellar
atmosphere, producing the dark lines seen in the spectrum. The most intense part of the rainbow is determined by the stellar temperature in
the regions where the light is produced (about 5800 K for the Sun) and the precise line pattern depends on which atoms and ions are most
efficient at absorbing radiation (H, Ca, Na and Fe for the Sun).