The optical portion of the spectrum in galaxies is due to light from stellar photospheres as can be seen in this comparison spectrum of a K giant star (marked S) and a typical elliptical galaxy (marked G).

Note that most of the metal lines (to an astronomer, the periodic table is H, He and metals) in the star are also seen in the galaxy spectrum. However, the galaxy line centers are redshifted (expanding Universe) and the galaxy lines are broader due to Doppler effects from the motion of the stars in the gravitational well of the galaxy.