Firstly a hydrogen molecule is broken into hydrogen atoms. The electron in a hydrogen atom absorbs energy and gets excited. The electron jumps from a lower energy level to a higher energy level and when it comes back to its original state, it gives out energy which forms a hydrogen spectrum.