Asked by: James Witts, Herefordshire
It's because light waves reflected from opposite sides of the thin bubble wall interfere with each other. Some wavelengths (colours) cancel each other out, while others are reinforced. The bubble wall is actually a thin film of water, protected from collapsing by a layer of detergent molecules on each side. And which colours are reinforced depends on the thickness of the water film.
If you look closely at the bubbles in your bath, you'll notice that the colours gradually change as the water films drain under gravity. Isaac Newton noticed the same thing one day when taking a bath and turned the observation to good use by setting up an experiment where all of the water eventually drained from the top of the bubble. It left a black spot (now called a 'Newton black film') consisting of just the two layers of detergent molecules. By following the change in the colours, Newton was able to calculate the size of the detergent molecules - a truly remarkable achievement.
Get more fascinating Q&As from BBC Focus magazine by following @sciencefocusQA