The life of a star spans many years, anywhere from millions to billions. They all start the same way, though — as massive clouds of gas, dust, and various other types of debris. These clouds are called nebulae, and they exist for millions of years before they begin to collapse in on themselves and create a star. As myriad occurrences disturb and change a nebula's shape and structure over millions of years, it slowly begins to shrink, spin faster, and heat up until a white-hot core called a protostar appears. Once the protostar is formed, it spends the next handful of millennia continuing to heat up and draw more and more matter towards itself until it reaches a critical temperature of around 27 million degrees Fahrenheit.
At this point, nuclear fusion is achieved in the protostar's core and earns it the title of "main sequence star." In this stage, the star is considered to be in a stable state and starts to glow brightly — bright enough for us to see on Earth. Stars stay in this stage for millions or even billions of years, and it's the stage our sun is in now. There's one more stage every star goes through before their paths start to diverge based on their mass, and this is called the red giant phase.
What is a red giant?
During the main sequence phase, nuclear fusion in the core of the star converts hydrogen to helium, and it's when this stock of hydrogen starts to run out that the star moves onto the next stage in its lifecycle. Without the nuclear fusion reaction to generate heat, the core loses stability. Outside of the core, there's still plenty of hydrogen, and as temperatures drop, it expands and cools, creating a star that's large and red in appearance — a red giant.
Back in the core of the star, all the helium that was created during the main sequence stage now fuses into carbon — the most important element for life. Everything from plants to animals and humans consists of carbon, and it's believed that all of the carbon in the universe was created through this fusing process within the cores of red giant stars. You might have heard before that everything on Earth is made from stardust, and in this sense, it really is true.
What happens after the red giant phase depends entirely on the mass of the star. Stars come in various sizes, with the smaller end of the scale a mere tenth of our sun's mass to the largest known stars eclipsing ours by 200 times. Comparing other stars to our sun is how we measure them — our sun is a lightweight star, and anything five or more times its size is a heavyweight star.
How lightweight stars die
For lightweight (or low-mass) stars like our sun, once all of the helium in its core has fused into carbon, it will collapse in on itself again. As this happens, the outer layers expand outwards, and the remaining energy from the core ionizes these gasses and causes them to glow. This phenomenon is known as a planetary nebula (though it has nothing to do with planets), and it lasts for just 20,000 years — which is no time at all in the context of a star's life.
Once the planetary nebula dies off, only the core of the star remains, and the star becomes a white dwarf. In size, white dwarfs are usually about as big as Earth, but in mass, they far surpass us. According to NASA, a teaspoon of white dwarf material would weigh more than a pickup truck. By this point, it's not generating any heat, and it's no longer bright enough for a human eye to see it from Earth. The light that it does emit, despite the name, can also shine blue or red as well as white, and over the course of a few billion years, it slowly cools and fades.
The last stage of life for a star this size begins once all of the heat dissipates, and it has no energy left to give. At this point, it becomes known as a black dwarf — it emits no light, creates no energy, and simply exists in space forever.
How heavyweight stars die
For high-mass stars that are five to 200 times bigger than our sun, extra energy causes additional chemical reactions in the star's core during the red giant phase. Helium fuses into carbon, and the increased gravity pulls these new carbon atoms together and fuses them further. This creates oxygen, then nitrogen, and lastly, iron. Once everything in the core has been fused into iron, there's no way for the reaction to continue because fusing iron takes more energy than is emitted by its creation. So, the fusion within the star's core stops, and the temperature suddenly rises even further as the iron atoms are squished together. When it hits 180 billion degrees, the repulsive force between the atoms surpasses the force of gravity, and the core explodes and creates a giant explosion — what we call a supernova explosion.
The shockwave, carrying massive amounts of energy, fuses materials it comes into contact with, creating heavy elements and an expanding cloud of hot gas called a nebula. A very dense object known as a superdense neutron star is left behind, and when a star more than 10 times the mass of our sun explodes in this way, there's a chance it can leave behind the densest object of all — a black hole.
What kind of star lives the longest?
The smallest type of main sequence star is known as a red dwarf, and they have as little as a third of our sun's mass. Because they're so small and so cool compared to other stars, the fusion reaction that happens within their cores has a unique effect. As helium is produced, the energy it creates radiates outwards and carries material to the star's surface. Here, it cools before sinking back down into the core, bringing new stocks of hydrogen along with it. This means more fuel for the star, leading to a longer life.
Because this cycle continues, it means the red dwarves don't run out of fuel, collapse, and continue into a new stage of their lifecycle as quickly as other stars. In fact, scientists estimate that some red dwarves will have life spans as long as 14 trillion years — and the universe hasn't even been around that long yet.