Looking back at my childhood, some of my fondest memories were those sunny days when my siblings and I could just run around and blow bubbles. It was so amazing to us how we could create something so entertaining out of the simple soap solution. To go along with the mystery of making bubbles, we always were perplexed by how the bubbles always had a shimmery rainbow color to them. As kids we wrote it off as magic, but now I know that there are laws of physics at work here.
The reason that soap bubbles have their colorful sheen has to do with the physics of light. When our eyes pick up ordinary light, like light from the sun for instance, it appears to us to be white. In reality, however, this light that we are seeing is actually comprised of an entire spectrum of colors. Each color possesses a different wavelength of electromagnetic radiation, but we can only see a tiny portion these. The wavelengths of light that we can see is called the "visible spectrum," and is made up of red, orange, yellow, green, blue, and violet. Rays of light travel in straight lines, but when they encounter obstacles one of several things can happen. If light comes to a reflective surface, like a mirror, it will bounce back. A collision with an opaque surface will cause light to be blocked, and this is what forms shadows. If there is a hole in that opaque surface, this will cause the light to diffract through that hole and spread out to the other side. Diffraction is defined as the bending of light as it passes around an object. When light rays pass from one medium to another, some rays bounce back while others go through. The parts of the light that pass through usually change direction through this process, bending at the point that the two mediums meet. This kind of bending of light is called refraction, and this is what is responsible for the "rainbows" seen in bubbles.
Bubbles function as a transparent medium that forces light to bend when it passes through it. The bending that occurs allows us to see some of the different colors that make up the rays of white light. In this way, bubbles act as delicate floating prisms, that separate the wavelengths of the light and allow us to see them as colors.