What determines the colors of the spectral emission line produced by a gas in a discharge tube

The colors of the spectral emission line produced by a gas in a discharge tube are determined by the energy levels of the atoms or ions in the gas. When a high voltage is applied to the gas, it gets excited and its electrons move to higher energy levels. As these electrons return back to their original energy levels, they emit light of specific wavelengths. The wavelengths of this emitted light correspond to specific colors. The energy levels and therefore the wavelengths of the emitted light are unique to each element or compound, which is why different gases produce different colors in a discharge tube.