when you add energy, electrons move to a higher energy level (orbit). WHen they come back down, they release energy. If that energy (wave length) is in the visible light range, we see color.
Dark-line spectrum is a "photo-negative" of emission spectrum. It is the gaps that appear in precisely the same location as corresponding bright lines. produced by a cool gas with a hot solid and you