Stars balance energy released by thermonuclear fusion with gravity based on their massive size. Most stars fuse hydrogen into helium, releasing light and thermal energy. Stars hold together because the large amount of matter involved compresses the gas, forming a luminous sphere. This process is known as hydrostatic equilibrium.
Stars form when hydrogen gas clouds condense into a concentrated area. The resulting mass compresses the hydrogen cloud into a sphere, forming a protostar. As more matter collects, the cloud collapses, increasing its density until the hydrogen begins to release energy through thermonuclear fusion. This causes the gas cloud to expand until equilibrium between the gravitational forces compressing the gas cloud balances with the expansion. The fusion reactions at the core transport thermal and radiant energy to the surface of the sphere that radiate into space.
The life cycle of a star depends on its mass. Once a star begins its fusion, it enters the main sequence and maintains its hydrostatic equilibrium for billions of years. Very massive stars glow with blue light and expend their fuel more quickly, finally collapsing as gravity compresses the remaining matter. This collapse often results in a supernova that ejects the star’s material into space. Smaller stars undergo this type of collapse, but they do not always explode. Every star on the main sequence eventually expends its fuel and begins a process of collapsing and expanding into a red giant before collapsing into a a white dwarf.