If the Sun is a giant ball of gas, why does it appear to have a sharply defined surface? The answer lies in the opacity of the gas — its ability to obscure light passing through it. The density and temperature of the Sun decrease smoothly and continuously moving outwards from the core. In other words, the Sun just trails off gradually into space, there is no hard or sudden edge in any property like density. However, it appears to have an edge because of the way the transparency of that material changes moving out from the center.
Schematic of the parts of the Sun. Click here for original source URL
Photons are continually colliding with particles, but as they migrate outwards, there is a point where the density is low enough that no more collisions occur. The photons travel unimpeded to the Earth, and we see an "edge" at that point. A solid probe, if it could survive the high temperature, could drop directly through the photospheric "surface" and plunge into the Sun, like an airplane passing through the surface of a cloud. Inside a cloud, for example, light bounces off water droplets. The edge of the cloud corresponds to a region where the density of water droplets is low enough that light travels freely outwards. As with a cloud, there is no sharp discontinuity in density or temperature at the photosphere of the Sun.
Energy ascending from inside the Sun heats the photosphere — the bright surface layer of gas that radiates the visible light of the Sun — to a temperature of about 5770 Kelvin. The convection of gas that mottles the solar surface is very similar to the convection of terrestrial cloud. Sunspots indicate the presence of magnetic fields. The pattern of gas that links sunspot pairs is very similar to the pattern of iron filings that trace the lines of force in a magnet. Astronomers have a set of diagnostics to probe the physical conditions of surface layers of the Sun, and even some indirect diagnostics of conditions deep in the core, which is not visible to us.