The light from the Sun, a filament lamp, a candle flame, produces a continuous spectrum. The light from a gas discharge lamp however produces a discrete line spectrum. For example, the hydrogen gas atoms emit visible light of wavelength 656.3 nm, 486.1 nm, 434.0 nm, 410.2 nm, 397.0 nm, 365 nm (called the Balmer series), and nothing in between. Why?
It turns out that the electrons in a gas atom can only exist at certain energy levels. As a result, when the gas atom is excited (by the high voltage in the gas discharge tube), an electron in the atom can only be excited occupy not just any energy level, but only certain allowed energy levels. Subsequently, when the electron de-excites from a higher energy level to a lower energy level, a photon is emitted. And the energy of the photon is equal to the difference in the energy levels.
Since the energy levels are discrete, the electrons cannot de-excite from any energy level to any energy level. They can only de-excite from one of the allowed energy levels, to another of the allowed energy levels. As a result, only photons of certain energy levels, are emitted. Since E=hf, it follows that only light of only certain frequency and wavelength (E=hf), are emitted.