Stellar evolution begins with nebulae, large clouds of gas and dust where stars form under the influence of gravity. As nebulae contract under their own gravity, the pressure and temperature increases, forming glowing protostars at the centers of contracting gas clumps. Once the core is dense and hot enough, nuclear fusion of hydrogen to helium begins, releasing energy and marking the birth of a star. The size of a star is determined by the balance between gravitational collapse and pressure from nuclear fusion. Over their lifetimes, stars evolve from the main sequence through red giant phases as their cores shrink and outer layers expand and cool. The final fate of a star depends on its original mass, becoming a white dwarf, neutron star, or black