White light consists of 7 colours, each has its own wavelength.
Light travels through space in a straight line as long as nothing disturbs it. As light moves through the atmosphere, it continues to go straight until it bumps into a gas molecule. Gas molecules are smaller than the wavelength of visible light. If light bumps into them, it acts differently. When light hits a gas molecule, some of it may get absorbed. After awhile, the molecule radiates (releases, or gives off) the light in a different direction. The color that is radiated is the same color that was absorbed. The different colors of light are affected differently. All of the colors can be absorbed. But the higher frequencies (blues) are absorbed more often than the lower frequencies (reds).
The diagram below will help in understanding the process further.