Generally speaking, the sky is black, because when you’re looking at the sky, you’re looking at outer space, as the earth’s atmosphere is invisible around us. But the sky is blue because of the visible light from the sun. The sun’s light is made up of the whole prism – in other words, all the colours that you see in a rainbow. As the light hits the earth’s atmosphere, refraction occurs, and it’s the blue spectrum that we see because it’s on a shorter wavelength than the other colours, including red, yellow and green.
Why we see light better in shortwave is more of a question for an astrophysicist than a meteorologist, but the molecules in the atmosphere scatter blue light from the sun more than the other colours. Depending on where you are, from which angle we’re looking at the light dispersal, it changes shade. For example, the closer you are to space, the darker the shade of blue. When the sun starts going down, you often see different colours as they become more refracted, so there could be more red, or orange, or a bit of green here and there, as the blue loses the ability to be seen. But closer to the horizon, as light passes through more of the atmosphere to reach us, the sky fades to a lighter blue or white.
This is a question that has puzzled some of the greatest minds over the centuries, including Aristotle, Isaac Newton and James Clerk Maxwell. That beautiful blue hue is the result of many factors coming together, the colours in sunlight, the angle at which the sun’s rays travel through our atmosphere, the size of atmospheric molecules and particles, not to mention the way our eyes perceive colour.
First we need to take a closer look at light, which we can think of as being a kind of energy that travels in waves. Sunlight or visible light may appear white but it's actually made up of a spectrum of different colours, remember those prism experiments at school that split light up into a rainbow of colours?
Light travels through space in a straight line as long as nothing disturbs it. In our atmosphere that can happen when light bumps into a gas molecule, mostly nitrogen and oxygen. What happens next depends on the wavelength of light.
Most of the longer wavelengths, the red and orange, will pass straight through. But the shorter wavelength light, the violet and blue, gets absorbed by the tiny gas molecules. The absorbed blue light is then radiated in different directions and scattered all around the sky, a process known as Rayleigh scattering.
Whichever direction you look, some of this scattered blue light reaches you. Since you see the blue light from everywhere overhead, the sky looks blue. In case you're wondering why the sky isn't purple, that's down to biology and the fact our eyes, specifically the cones or colour receptors in our retina, are more sensitive to blue than violet.