Sun is white, not yellow. For you graphics
people or web developers out there, the exact color of the sun is #fff5f2. The
reason the Sun looks yellow to us on Earth is that our atmosphere scatters
light from the Sun; so the apparent color of the sun changes. This same
scattering effect is why the sky looks blue in the day time instead of black,
like at night.
Specifically, what is going on here is the
Earth’s atmosphere scatters light in the blue and violet wavelength range, so
the remaining wavelengths of light appear yellow. This same effect is why the
sky will also often appear yellow when the Sun is disappearing over the
horizon, as well as why the sky/Sun can appear more red at times during this
phase of the day.
As the sun is setting, more of the shorter
wavelength blue is being scattered because of the decreased angle of the sun
relative to you; thus the light has to pass through more atmosphere to get to
you. This increased diffusion results in less of the blue wavelength being visible
to you and thus what remains appears yellow. Similarly, if it is dusty or there
are a lot of other larger particles in the air, this will filter out larger
wavelengths, resulting in a red sky and red sun.