The Universe is filled with stars, some big, some small, and some utterly giant. They are what make the cosmos the bright and shiny thing it is today, and work on the principle of Nuclear Fusion. Stars fuse lighter elements into heavier elements, releasing energy in the process that keeps them burning. However, stars are not infinitely massive, and are bound to run out of stuff to fuse at some point.
This time, we focus only on the lighter stars, and what happens at the end of their life.
Every star begins from a Nebula, a cloud of hydrogen and helium that starts to compress because of the gravitational pull. Nuclear fusion cannot take place below a threshold temperature. As soon as it gets hotter than 13 million Kelvin, hydrogen can finally fuse into helium, and voila! A star is born.
The lifespan of a star is till the time the core can sustain nuclear reactions to balance the inward pull due to gravity. As soon as the fusion stops, gravity wins the long war and an inward collapse commences. Since a small star has a lower gravitational pull, it has to undergo fewer nuclear reactions to sustain it. Hence, a smaller star lives much longer than larger ones.
Stars having mass less than 3 times the mass of the sun can go on for billions of years fusing hydrogen. The Sun is estimated to run out of hydrogen in the next 5 billion years. But eventually, it will. And that will lead to the next phase of its life.
When there is no more hydrogen to fuse, the star begins to contract, heating up the core. Helium starts to fuse into heavier elements after the core temperature exceeds 100 million Kelvin. Helium fuses into carbon and oxygen. This releases energy all of a sudden, which causes the outer layers to expand. The star gets larger in size, and redder, since helium fusion provides lesser Energy, and red has the lowest energy in the visible spectrum. This phase is called a Red Giant.
In a few billion years, the Sun too will form a red giant, engulfing the orbits of Mercury, Venus and Earth.
The star goes through multiple phases now: after fusing the helium, it then fuses carbon into Magnesium, Neon, Sodium and other elements. Then, these elements fuse to form even heavier elements. Basically, the star tries to keep fusing elements to battle gravity. In smaller stars, the fusion can go on till only lighter elements, because such stars cannot generate enough pressure to fuse them further. Quantum mechanical effects stop the atoms and nuclei from coming too close, and there is an ever-lasting balance established between the repulsive quantum mechanical forces and attractive gravitational force.
The star comes down collapsing under its own gravitational pull. However, it does not collapse entirely. The Pauli Exclusion Principle states that fermions, such as electrons and protons, cannot occupy the same quantum state. This creates a repulsion that counterbalances the gravitational pull. Slowly, in the absence of any source of energy, the outer layers of the stars shed off.
The star is now a white dwarf – the last phase in the life of such a star. Such stars glow very dimly for billions of years, eventually radiating away all the energy it had. It then becomes a Black Dwarf, a lifeless lump of matter that will exist for eternity.
The outer layers of such stars that get shed off are full of heavier elements such as carbon, oxygen, neon and so on. However, they also contain small amounts of hydrogen and helium that remains unused.
Heavier stars live shorter lives, and they are violent as well. Such stars are responsible for the most energetic events in the universe, such as gamma ray bursts.
More on the lives of heavier stars later.