Life Cycle of a Star
All stars form in a stellar nebula, which is a huge cloud of gas and dust. Though they shine for many thousands, and even millions of years, stars do not last forever. The changes that occur in a star over time and the final stage of its life depend on a star's size.
Nuclear reactions at the center (or core) of a star provides energy which makes it shine brightly. This stage is called the 'main sequence'. The exact lifetime of a star depends very much on its size. Very massive stars use up their fuel quickly. This means they may only last a few hundred thousand years. Smaller stars use up fuel more slowly so will shine for several billion years.
Eventually, the hydrogen which powers the nuclear reactions inside a star begins to run out. The star then enters the final phases of its lifetime. Average stars will expand, cool and change colour to become a red giant. The more massive stars will become a red supergiant, which is much larger. What happens next depends on how massive the star is.
A smaller star, like the Sun, will gradually cool down and eventually stop glowing. During these changes it will first go through the planetary nebula phase, when a dying star sheds its outer layers. After the layers are shed, a white dwarf is the core of the star that has been left behind. After many thousands of millions of years it will stop glowing and become a black dwarf.
After becoming a red supergiant, a massive star experiences a much more energetic and violent end. It explodes as a supernova. This scatters materials from inside the star across space. This material can collect in nebulae and form the next generation of stars. After the dust clears, a very dense neutron star is left behind. These spin rapidly and can give off streams of radiation, known as pulsars.
If the star is especially massive, when it explodes it forms a black hole. This forms a region in space where gravity is so strong that nothing, not even light, can escape.
Credit: https://www.schoolsobservatory.org/