Sunlight contains all the colors of the visible spectrum blended together, which is why it looks white in space. From the ground it looks yellow, and the reason involves our atmosphere.
Why the Sun is white in space
Above the atmosphere, nothing filters the Sun’s light, and astronauts have photographed it appearing white.
How the atmosphere changes its color
Air molecules scatter short blue wavelengths more strongly than long red ones, a process called Rayleigh scattering. That scattering is why the sky looks blue. Because blue light is removed from the direct beam, the Sun appears more yellowish-white when you look at it.
The Sun’s temperature
The Sun’s surface is about 5,500 degrees Celsius. Its light is spread across many wavelengths, which together appear white to our eyes.