A star 's life begin with the gravitational collapse of a gaseous nebula of material composed primarily of hydrogen , along with helium and trace amounts of heavier elements . When the stellar core is sufficiently dense , hydrogen become steadily converted into helium through nuclear fusion , releasing energy in the process . The remainder of the star 's interior carry energy away from the core through a combination of radiative and convective heat transfer processes . The star 's internal pressure prevent it from collapsing further under its own gravity . When the hydrogen fuel at the core is exhausted , a star of mass 0 @.@ 4 times greater than the Sun 's will expand to become a red giant . In some cases , it will fuse heavier elements at the core or in shells around the core . As the star expand it throw a part of its mass , enriched with those heavier elements , into the interstellar environment , to be recycled later as new stars . Meanwhile , the core become a stellar remnant : a white dwarf , a neutron star , or if it is sufficiently massive a black hole .