In a rainbow, the white light is split into its components. The raindrops behave somewhat like prisms, dispersing the white light into its component colours. These are then internally reflected if the sunlight hits the water drops at the proper angle and emerge from the other end.
Formation of rainbow
When sunlight hits a rain droplet, some of the light is reflected. The electromagnetic spectrum is formed of light with many varying wavelengths, and each is reflected at a different angle. Thus, the spectrum is separated, producing a rainbow. A Rainbow is formed due to sunlight and atmospheric conditions. Light enters a water droplet, slows down and bends as it goes from air to water, denser. The light reflects off inside the droplet separating into its component wavelengths or colours. When light exits the droplet, it creates a rainbow. This happens when the rays from the sun come into contact with the raindrop at a certain angle.