Daytime sky color emerges from a simple clash between sunlight and the thin shell of gas wrapped around Earth. Space itself stays dark because it is almost empty, offering nothing to light up the way air does near the ground.
Sunlight arrives as a mix of wavelengths spanning red to violet. As it enters the atmosphere, photons collide with nitrogen and oxygen molecules. This process, known as Rayleigh scattering, redistributes light more efficiently at shorter wavelengths. Blue and violet light scatter strongly in many directions, while longer wavelengths such as red and orange pass through more directly toward the surface.
Human visual perception and solar intensity complete the effect. The human eye is less sensitive to violet, and some violet and ultraviolet are absorbed or filtered, so the scattered light that dominates our vision is blue. Meanwhile, when you look sideways through the atmosphere, your line of sight intersects huge numbers of molecules, increasing the integrated scattering cross section and turning the sky into a bright dome rather than a dark ceiling.
Look instead toward regions with little or no air, such as the view from orbit or from high altitudes pointed away from the Sun, and the scene changes. With almost no molecules to scatter incoming radiation, the path is optically thin, revealing the black backdrop of space that coexists with the blue shell generated by Earth’s atmosphere.