atoms emit light when electrons in a higher energy orbital drop to a lower energy orbital. The energy of the emitted photon matches the energy lost by the electron and that energy determines the colour (blue is higher energy than red, UV even higher than blue and so on).