How do rainbows work?
During and after a rain shower, the atmosphere is filled with water droplets. In order for a rainbow to be seen, the sun has to be right behind you. When light passes through those water droplets, the light is leaving one medium and entering another. This causes the light to change its direction and bend, which is a process called refraction.
When the light is refracted in the water droplets, the light is split into seven different colors. The colors are red, orange, yellow, green, blue, indigo, and violet. They are always in that order. One way to remember the colors and the order is by remembering the name ROY G. BIV. Each letter in the name is the first letter in each color of the rainbow.
The refraction that occurs in the water droplets to form rainbows also occurs in other places too. When light passes through a prism, the colors that are in rainbows are projected onto the wall (or whatever surface is near). Rainbows can also be seen in bubbles. The light passing through a bubble is refracted through the outer wall of the bubble and reflected onto the inside wall of the bubble.